Skip navigation

How do I go about blocking websites using Sudo in Terminal?

1534 Views 18 Replies Latest reply: May 26, 2012 1:29 PM by thomas_r. RSS
1 2 Previous Next
AugustusPrimus Calculating status...
Currently Being Moderated
May 26, 2012 7:09 AM

Nobody in the Kenwood Towne Center locations seems to know how or they are to scared. I came here so that if anything went wrong they would be the ones responsible & it under warranty not me.

MacBook Pro (13-inch Late 2011), Mac OS X (10.7.3)
  • thomas_r. Level 7 Level 7 (27,060 points)

    Sudo is not a tool that you would use to block websites.  I'm guessing that you're looking for directions for blocking sites by editing the hosts file, but note that that is a poor solution, and not adviseable for anyone who is not already comfortable with the Terminal.


    I would advise using OpenDNS, which is free and offers site blocking features.

  • Linc Davis Level 10 Level 10 (108,150 points)

    First, you may be under the impression that you're getting official support from Apple here. That's not the case. Apple explicitly disclaims responsibility for the information on this site.


    Second, it's not clear what you want to do. If you want to filter out ads on web pages, I suggest the ad-blocking proxy called "GlimmerBlocker."

  • ds store Level 7 Level 7 (30,305 points)

    You can use


    sudo pico /etc/hosts


    and arrow down to the bottom of the existing file (change nothing there) and add




    to block, and then press Control X,  Y + return to save and exit.


    Screen shot 2012-05-26 at 11.13.37 AM.jpg



    However for more sites/entires it's better to use the free TextWrangler as it can edit the /etc/hosts file in a more GUI like manner, paste longer information etc.


    I use a 16,000 plus hosts file modification to block a lot of the crap of the Internet, been deciding to write a user tip, if it's too risky as messing around with this system level file is dangerous.

  • ds store Level 7 Level 7 (30,305 points)

    AugustusPrimus wrote:


    What I want to do is completly block inappropriate websites for example playboy to name one of the hundreds if not thousands of pornagraphic websites that a curious teenager would adventure to.


    I answered your original question, however since adult content websites number in the hundreds of thousands, new ones created everyday, it would be unrealistic to use the hosts file for this.


    My list is only 16,000 and generated by thousands of IT workers, the amount of adult content online is well in excess of being managed except by a population of say New York City working on it 24/7 to get it all catagorized.




    If you subscribe to OpenDNS, they do have a decent adult content filtering system, but it's not perfect at all as I tried it, it does a good job of blocking a lot of accidential visits to major known sites, but not if one is smart, learns the bypass trick from a friend or/and their intent is to find that material as it's everywhere.




    OpenDNS may slow down your downloads of Apple/Akamai based content which uses the closet ISP server to download to you.


    You need to check your location that OpenDNS has a server near your location or experience slow or problematic downloads.


    You can search Wikipedia for OpenDNS, their server locations are there, if your ISP server is very near the same city, then you should't experience a delay in downloading from Apple/Akamai servers.



    If I'm talking too geek speak, then just copy my post for later and likely it will make sense if you run into a problem.



  • Linc Davis Level 10 Level 10 (108,150 points)

    According to a quick search I just did, there were about 4.2 million "inappropriate" websites in 2007. There must be many more now, and of course, they're changing all the time. Each entry in the hosts file will block exactly one. So make sure you set aside enough time for your project.


    Otherwise, use Parental Controls.

  • eww Level 9 Level 9 (52,975 points)

    AugustusPrimus: It's not "hundreds or thousands" of **** sites. More likely it's hundreds OF thousands, and hundreds more every day. Lotsa luck keeping a teenager away from them all. That'll be like keeping your yard dry by running around trying to catch raindrops one at a time. By blocking access to even a few of the major sites at home, you'll just encourage the kid to use a friend's computer instead.

  • thomas_r. Level 7 Level 7 (27,060 points)

    Mister Reed no duh it is not adviseable, but how is anyone ever going to learn without experiencing?


    So, then, do you have to stick your hand into a garbage disposal and turn it on in order to learn that you shouldn't do that?  Criticizing someone who advises you not to do that is ridiculous.


    If you choose to edit the hosts file, you can certainly do that, but you may end up making your Mac completely unable to connect to the internet.  Besides which, how do you suppose you're going to build and constantly maintain a list of all the bad sites out there that you don't want your teenager using?


    As I already recommended, use OpenDNS.  That is free, requires installation of no software and can block whatever sites you want.  You can even configure your wireless router to use OpenDNS and block access to those sites on any device on your wireless network.

  • thomas_r. Level 7 Level 7 (27,060 points)

    OpenDNS may slow down your downloads of Apple/Akamai based content


    I've never heard such a claim before, nor has that been my experience as a user of OpenDNS.  Do you have a source for this claim?

  • ds store Level 7 Level 7 (30,305 points)

    Thomas A Reed wrote:


    I've never heard such a claim before, nor has that been my experience as a user of OpenDNS.  Do you have a source for this claim?


    Your one of the fortunate that has a OpenDNS server nearby, or no in between line issues. Unlike Grant who is in Boston and has to use NY OpenDNS servers.




    You can follow the discussion about Grant's OpenDNS problem here in the Lounge (sorry others not allowed, Level 6+ only)


  • thomas_r. Level 7 Level 7 (27,060 points)

    The veracity of those claims seems to be a matter of some debate.  Certainly, the idea that you can't download fast from a server on the other side of the planet is extremely flawed.  I can and have done exactly that.

  • Linc Davis Level 10 Level 10 (108,150 points)

    Any halfway-intelligent teenager would know, or could find out, how to bypass the controls imposed by OpenDNS.

  • thomas_r. Level 7 Level 7 (27,060 points)

    If your teenager is tech-savvy enough enough to figure that out, there's nothing you'll do to keep them away from such sites.  And as you pointed out earlier, they can always just go to a friend's house or use a public wifi hotspot.  Parenting does not involve any absolute solutions, but OpenDNS (or some other site blocker) can be used effectively as a part of your parenting.

1 2 Previous Next


More Like This

  • Retrieving data ...

Bookmarked By (0)


  • This solved my question - 10 points
  • This helped me - 5 points
This site contains user submitted content, comments and opinions and is for informational purposes only. Apple disclaims any and all liability for the acts, omissions and conduct of any third parties in connection with or related to your use of the site. All postings and use of the content on this site are subject to the Apple Support Communities Terms of Use.