Apple Event: May 7th at 7 am PT

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Cannot modify '/etc/hosts' as administrator

Hi all,


I know there're a lot of discussions and solutions to this question, but my case is very strange. I have tried all the methods I've seen on the internet, including

  1. sudo nano /private/etc/hosts
  2. sudo vi /private/etc/hosts
  3. sudo /Applications/TextEdit.app/Contents/MacOS/TextEdit /etc/hosts (I encountered an error by running this command: TextEdit[5872:3e07] NSTrackPersistentURLs: LSSharedFileListInsertItemURL() failed at inserting URL file://localhost/private/etc/hosts (/private/etc/hosts) )
  4. Manually change permissions of private and etc foloder through Finder
  5. Use the system preference pane 'Hosts'
  6. Use Gas Mask


All methods I used above have problem overwriting the file (1, 2 said my hosts file is read only and I'm not permitted to overwrite, 5,6 didn't make a change on hosts file after I edited and saved). The account I'm using is an admin account, so I should have the permission to overwrite the hosts file. I used to be able to edit the hosts file and this problem only comes out early this year. I doubt if my hosts file is somehow damaged? Has someone here experienced it and is able to help me figure it out? I would really appreciate it.

Mac Pro, Mac OS X (10.7.5)

Posted on Nov 27, 2012 6:52 PM

Reply
18 replies

Nov 30, 2012 1:59 PM in response to hakerjack

For reasons only you know, you have locked the hosts file, as well as adding an inappropriate ACL to the etc directory. I'll limit myself to fixing the hosts file. Enter the following command in the same way as before -- NO TYPING:


sudo chflags nouchg /etc/hosts


You'll be prompted for your password, which won't be displayed when you type it. Type nothing in the window except your password. Then quit Terminal.

Cannot modify '/etc/hosts' as administrator

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