Hosts file- Can't save

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.

MacBook Pro, Mac OS X (10.6), 15"s of circuit board

Posted on Sep 4, 2009 3:33 PM

Reply
16 replies

Sep 4, 2009 3:52 PM in response to Hierkosmo

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.

Sep 4, 2009 3:44 PM in response to V.K.

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 w\out 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

Sep 4, 2009 3:57 PM in response to V.K.

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.

Sep 27, 2009 9:18 PM in response to Hierkosmo

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?

Sep 4, 2009 3:41 PM in response to Hierkosmo

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.

Sep 4, 2009 4:08 PM in response to V.K.

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.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Hosts file- Can't save

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.