11 Replies Latest reply: Nov 22, 2009 8:02 AM by lune
gillylinus Level 1 Level 1 (0 points)
Hi, I've been wanting to block a certain website so my friends can't use it on my computer, and I'm running into trouble when using the Terminal method.

I type in sudo pico /etc/hosts, my password, and then 127.0.0.1 http://www.website

and then I've tried ctrl o, which tells me it's written the file (saved?), I exit out of the terminal, and open Safari and the website isn't blocked. Am I missing a step? When I hit ctrl o it gives me the file name /etc/hosts -- do I need to change that?

Mac Book Pro, Mac OS X (10.5.7), Safari Version 3.2.3
  • Golden Shoes Level 5 Level 5 (4,015 points)
    Greetings,

    The Hosts file is just a text file located in the /etc directory that you can edit with any text editor; no need to use Terminal and Pico to do it. Did you enter 0.0.0.0 domainname.com, and then save the changes? Did you reboot your Mac before you tried it in Safari? Be sure to do that.

    If you don't want to manage Hosts using a text editor or with Pico, you can also use Hostal, which is only $9.99.
  • andyBall_uk Level 7 Level 7 (20,490 points)
    Hi

    I believe the correct file is /private/etc/hosts on a mac - certainly on mine, anyway.
  • Golden Shoes Level 5 Level 5 (4,015 points)
    Well, it's in /etc on mine; always has been.
  • gillylinus Level 1 Level 1 (0 points)
    I tried that too, but it still hasn't worked. Hm.

    Is the /etc directory part of the directory utility? Looking at that, I can only see two domains, /local and /bsd. Maybe it doesn't know it's there?
  • Golden Shoes Level 5 Level 5 (4,015 points)
    I'm not sure what you mean by a directory utility. The /etc directory is a hidden directory; you can access it from the Finder by choosing Go>Go to Folder… and entering /etc and press Return or click the Go button. Inside that directory is a file named Hosts; that's the one you want.
  • Eme Level 5 Level 5 (5,635 points)
    Mine is as well.......
    apple
  • Golden Shoes Level 5 Level 5 (4,015 points)
    But what OS version are you running: 10.4.11 or 10.5.x? It's in different locations for each of them?
  • Omar.KN Level 1 Level 1 (0 points)
    I tried that too, but it still hasn't worked. Hm.


    Have you tried to reload the page you want to block?

    Safari will load the url as long as it is in the cache, even after a reboot of the mac!

    bw, Omar K N
  • lune Level 1 Level 1 (140 points)
    Hi
    I was just trying to do the same thing, i.e blocking access to a specific website.
    I looked a the/etc/hosts file which reads

    Host Database
    #
    # localhost is used to configure the loopback interface
    # when the system is booting. Do not change this entry.
    ##
    127.0.0.1 localhost
    255.255.255.255 broadcasthost
    ::1 localhost
    fe80::1%lo0 localhost


    Do I just need to add on a new line as mentioned before,
    0.0.0.0 domainname.com
    and save it.
    or do I need the http://

    I have also in the /etc folder these files
    hostconfig
    hostconfig~
    hosts.equiv

    Which I am not sure what they are for

    Many thanks
  • Charles Minow Level 6 Level 6 (9,190 points)
    Hi--

    lune wrote:
    Do I just need to add on a new line as mentioned before,
    0.0.0.0 domainname.com
    and save it.
    or do I need the http://


    Definitely don't use the "http://" part. That would make it not work.

    I have also in the /etc folder these files
    hostconfig
    hostconfig~
    hosts.equiv

    Which I am not sure what they are for


    The first two are for setting up certain settings like whether or not your computer runs a mail server, QuickTime Streaming Server, etc. The first is the actual file as used by the OS and the second, with the "~" character, is a backup.

    The hosts.equiv file is used for storing host and user information relating to allowing remote logins. That's nothing to do with blocking web sites via the hosts file.

    charlie
  • lune Level 1 Level 1 (140 points)
    Many thanks for the quick answer.
    I'll have a go at it.
    I found that adblock doesn't necessarily block certain pop-up junk even after adding custom addresses. Some poker/gambling site comes to mind.
    Cheers