Published on August 10th, 2012 | by Admin0
Editing hosts file in Mac OS X
1.) Open the Terminal by either by clicking on Applications, then Utilities and then Terminal, or by pressing Cmd-Spacebar to open Spotlight, typing Terminal and pressing Return(enter). The Terminal window should look like this:
2.) In order to open the hosts file for editing in the Terminal. Enter the following command (or Copy and Paste from below) at the Terminal prompt:
sudo nano /private/etc/hosts
Press Return. Terminal will ask you to enter your Administrator Password:
Type your password and again press Return.
3.) The hosts file will open in the Terminal window for editing
To navigate the hosts file, use your arrow keys to move up and down. The lines beginning with the hash (#) symbol are comments and should not be edited. There will also be some default mappings, such as the entry 127.0.0.1 for localhost. Use the ↓ Arrow Key to move the cursor to a blank space at the bottom of the hosts file, and enter your new mapping here.
4.) To save the hosts file after editing, press Ctrl-o. This will bring up a prompt for the file name. Simply press Return to save the hosts file. You can then exit editing the hosts file by pressing Ctrl-x. This will return you to the Terminal prompt.
5.) For the changes to your hosts file to take effect, you must first flush your DNS cache. To do so, enter the following command (or Copy and Paste from here) at the Terminal prompt:
Press Return. You can now exit the Terminal and your new host mappings will be in effect.