Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
add comment

2 Answers

up vote 6 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
add comment

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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.