Skip to content

Instantly share code, notes, and snippets.

@safarista
Created December 29, 2012 18:24
Show Gist options
  • Save safarista/4408529 to your computer and use it in GitHub Desktop.
Save safarista/4408529 to your computer and use it in GitHub Desktop.
How to edit the hosts file in Mac OS X 10.6 Snow Leopard to Mac OS X 10.6 10.8 Mountain Lion

The hosts file is a text file that maps hostnames to IP addresses. On browser request, the system first checks if there is an entry in the hosts file, if exists gets the corresponding IP address. If no it resolves the IP via the active connection’s DNS servers.

The hosts file can be edited to block certain hostsnames, like Adobe's licence hosts, or used for web development purposes, i.e. to redirect domains to local addresses.

###Steps – Open the Terminal.app Either start typing Terminal in the Spotlight search, or goto Applications > Utilities > Terminal

type either of the commands below and enter your password

$ sudo nano /etc/hosts # This is just a symlink
$ sudo nano /private/etc/hosts

Move around with your arrow keys on the keyboard. Edit as you wish After editing, to SAVE and QUIT:

CTRL+O #ctrl plus Ohh, 
then ENTER
then CTRL+X

===DISCLAIMER===

With great power comes great responsibility. Be careful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment