Benches macOS

15

Hosts file- Can't save

apple Verified

Imported from the Apple Support Forums via the Wayback Machine 🔗

Hello All. I'm a new Mac purchaser, fairly decent user. Heavy PC user (MS certified).

Trying to edit the Host file but can't seem to do so.

I'm logged into the Computer as 'root'

In terminal I login to:

sudo nano etc/hosts

Since I'm root I am not asked for a pwd.

When I finish editing the hosts file and try to save, I:

press CTRL X.

I am asked to "Save Modified Buffer". I select Y for yes.

Next screen asks:

File Name to Write: etc/hosts

Under neith the above statement I have the options to:

^Get ^T M-M Mac Format M-M Mac Format M-P Prepend

^Cancel M-D Dos format M-D DOS Format M-A Append M-B Backup File

I hit enter to simply save the file and I get back:

Error writing etc/hosts: No such file or Directory

I also tried using the ^O command and it didn't work.

Looking at the obvious, don't the file and directory both exist since I am in the directory and I'm trying to edit the file?

Does the Mac not want to over write the hosts file?

Is this another snow leopard quark?

I managed to do this on my G5 PowerPC without any problems.

I called Mac support, since the Mackbook is only two days old and they said:

"uh, we're not allowed to show you how to edit the Hosts file because it can cause catastrophic damage to your OS and we don't want to be held liable for that."

Anyone, anyone? Bueller?

Thanks all.

15 replies

Sign in or join Beachball Help to reply.

  1. 0

    V.K.

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    that should be /etc/hosts not etc/hosts which does not exist.

  2. 0

    macwiz1220

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    Why are you logged into the root account? There is no need to ever do this. If you must use root privileges, do so with sudo from the command line. Being logged into root can be dangerous.

  3. 0

    Hierkosmo

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    Regarding use /etc host-

    The problem started when I couldn't access:

    sudo pico /etc/hosts

    Apparently that directory doesn't exist in Snow Leopard. The 1st time I called Mac the guy actually told me to use

    sudo nano etc/hosts wout the /.

    When I called back 45 mins later I was told they don't support editing the file.

    I'll try with the / and see how it goes.

    Danke.

    SMC

  4. 0

    macwiz1220

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    No / only works if your current working directory is / itself. If you don't use a /, the path is relative to your current location.

  5. 0

    Hierkosmo

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    Thanks Macwiz. Did you have an answer for my question?

    I logged into 'root' at the "advice" of the Mac support guy as
    he thought maybe it wasn't being able to be edited because I needed to be in root.

    Thanks again.

  6. 0

    V.K.

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    Hierkosmo wrote:

    Regarding use /etc host-

    The problem started when I couldn't access:

    sudo pico /etc/hosts

    Apparently that directory doesn't exist in Snow Leopard.

    no that's wrong. /etc does exist in snow leopard and the file /etc/hosts exists as well. the command should work too. it does for me. if you put sudo pico etc/hosts it will look for etc directory in the current folder you are in. that's your home directory by default unless you cd to / first.

  7. 0

    Barney-15E

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    If you are logged in as root, you don't need sudo (super user do). You already have way too many privileges as it is.

    I'm not sure why you got the response you did. I just edit the hosts file with TextWrangler.

  8. 0

    Hierkosmo

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    THANKS V.K and MACWIZ!!

    I used the /etc and it worked GREAT! My first clue should have been that the previous hosts file didn't include ANY entries, but when I used the /etc, BOOM, there it was.

    I guess my vision of all Mac Tech support guys at Mac has dwindled a little bit. Better, more knowledgeable support here and faster response.

  9. 0

    V.K.

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    you are welcome. btw, are you trying to use /etc/hosts to block some ad sites? I gave up on that idea a while ago because the ad sites change addresses too often.

  10. 0

    macwiz1220

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    It also slows down your internet connection, as the computer needs to look through the hosts file every time your computer makes a connection. Lots of entries can have a decent effect.

  11. 0

    Barney-15E

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    [This site keeps up pretty well|http://www.mvps.org/winhelp2002/hosts.htm]. They've got a link to the text file. I subscribe and get notified when it changes.

    I've been ad and double-underline free for two years.

  12. 0

    V.K.

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    thanks Barney. I may take a look at this one. however, I find that firefox popup blocker works pretty well and i don't feel like I really need to use /etc/hosts for the task. or maybe I just don't visit popup sites too often...

  13. 0

    Hierkosmo

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    Good info, thx Barney.

    VK- Yeah I was experimenting with the DNS to block sites. Looks like Barney could have something goin....

  14. 0

    Barney-15E

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    You just have to find the link to the text file. Othewise, they provide some sort of Windows installer file.

    I use TextWrangler to edit the /etc/hosts file. Keep the part that is already in the file, and add the list of ad sites to the end of the file.

  15. 0

    shiznit666

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    Hey All,

    So I am trying to block a website by editing my hosts file on OS X 10.6.1, and when I go to terminal and type "sudo nano /ect/hosts", this part doesn't even show up...

    ##

    # 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

    Then when I try to save it, it wont let me and it comes up with an error.

    Is there any way to fix this?