Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question
up vote 7 down vote accepted

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

share|improve this answer
1  
You 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 Jan 3 '10 at 14:54
    
well, i did it with vi (and i hate it). nano seems much more user friendly. Thanks anyway – Nava Carmon Jan 3 '10 at 15:54

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.

share|improve this answer
    
If you use this method be mindful of line endings. – ridogi Jan 3 '10 at 15:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .