You can’t just open up your editor of choice to modify the /etc/hosts file on your Mac. You can open the file without any problem, you just can’t save it.
To do this you must have super user privileges. Just being an Administrator isn’t enough. Fortunately, there’s a way to temporarily get super user privileges using the SUDO command. So I fired up Terminal and typed in:
Ruh-roh. It wouldn’t let me save the file. Crap. I’m not a Unix guy and VI makes my skin crawl and head hurt, but I was able to use sudo vi /etc/hosts and save the file.
So why couldn’t I get any of the GUI apps to save it?
Turns out, that you need to sudo the actual executable which is inside the TextEdit.app bundle. So the command I issued is this:
If you happen to own TextMate, then you can save yourself a lot of typing and heartache. TextMate installs a Terminal command called “mate” that allows you to perform the above sudo command. Just type:
BBEdit also has this capability:
TextWrangler as well:
Voila, again!! When you go to save your file, you will be prompted for your password.