How to edit host file on OSX Mountain Lion
The hosts file in Mac OS X is stored at /private/etc/hosts but can also be accessed at the more traditional location of /etc/hosts. If you’re looking to edit hosts, you’ll want to target the file located in /private/etc/ though.
We’ll walk through how to manually edit the hosts file in OS X Lion and OS X Mountain Lion with the command line using the simple text editor called nano. If you’d prefer to avoid the Terminal, you could try the easier method of using a preference pane.
- Launch Terminal , found in /Applications/Utilities/ or launched through Spotlight
- Type the following command at the prompt:
- Enter the administrator password when requested, you will not see it typed on screen as usual with the command line
- Once the hosts file is loaded within nano, use the arrow keys to navigate to the bottom of the hosts file to make your modifications
- When finished, hit Control+O followed by ENTER/RETURN to save changes to /private/etc/hosts, then hit Control+X to exit out of nano
- Quit out of Terminal when finished
sudo nano /private/etc/hosts