changing hosts file on snow leopard

3

1

I need to add an entry to my hosts file on Snow Leopard. I could edit the hosts file with root user enabled, but in the system doesn't let me to save this file saying that I don't have permissions to make changes to this file since it's located in non-writable directory. How do i save changes there?

Thanks,

Nava

Nava Carmon

Posted 2010-01-03T13:08:48.387

Reputation: 155

Answers

7

Try it from the command line:

sudo nano /private/etc/hosts

Type your user password when prompted for a password.

For more help, please refer to this blog posting:

http://decoding.wordpress.com/2009/04/06/how-to-edit-the-hosts-file-in-mac-os-x-leopard/

Please note that you might have to reset the DNS cache with this command after changing the hosts file:

dscacheutil -flushcache

Meta Bergman

Posted 2010-01-03T13:08:48.387

Reputation: 1 340

1You can only use sudo if you're logged in as an administrator. If you're not an administrator do su -l <admin-account-name> first. – Steve Folly – 2010-01-03T14:54:17.160

well, i did it with vi (and i hate it). nano seems much more user friendly. Thanks anyway – Nava Carmon – 2010-01-03T15:54:31.907

0

Wat you could also do, is copying the file to anywhere else, and edit & save it from there. Now drag and drop it in finder in the /private/etc/ folder. It should ask for admin permissions; just type in your admin password. Also, you probably have to change permissions on the hosts file afterwards.

Deniz Zoeteman

Posted 2010-01-03T13:08:48.387

Reputation: 1 001

If you use this method be mindful of line endings. – ridogi – 2010-01-03T15:26:52.820