[Quick Tip] Edit Hosts File on OS X Mountain Lion via Terminal Window

hosts file on mac

While on Windows 7 I can simply use a small tool like “HostEditor.exe” to edit and manipulate the “hosts” file, we may find cooler simple way to achieve that goal. By making use of “Terminal” window we can edit and setup “hosts” file configuration as we wish. Today we’ll show you how to edit Hosts file on Mac OS X Mountain Lion via Terminal. However this method will still be applicable to previous version of OS X like OS X 10.7 Lion.

Where Is The Location of Hosts File on Mac?
By default, we can see “Hosts” file located at “/private/etc/hosts” but can also be accessed at the more traditional location of “/etc/hosts”. So which one we should use? To make things more convenient, we should edit the one located at “/private/etc/”

How To Edit Hosts File

1- Launch Terminal window either via Mac’s Spotlight or via “/Applications/Utilities/”

2- Type following command by hitting enter next:

sudo nano /private/etc/hosts

3- You might be asked for Admin password. Type it and hit enter

4- Nano editor will show up displaying the whole content of “hosts” file

hosts file on mac

5- You can use arrow keys to navigate around.

6- Now go ahead edit each line as you wish.

7- Once done, hit [Control] + [O] keys on keyboard to save changes

8- You can review the “hosts” file once again

9- Once you are really sure, hit [Control] + [X] to exit

10- Done, you can now close that Terminal window.

Tips: You can edit hosts file to block ads from being displayed as well as other cool purpose. So, do not forget to bookmark this trick.

Subscribe

Thanks for reading articles on PressByte.com. You can get updates quicker via email. Subscribe freely below.

No Responses

Leave a Reply