Windows guy learns linux hosts files

The hosts file is like a local DNS that takes priority over the real DNS.

The average person won’t understand what that means.  In other terms, the hosts file is a local map of “domain name” to an “IP address”.  For example, normally would resolve to something like  If you go to you would see Google. is the same as

Now if you went into your host file and put an entry like…
Then Google would point to Bing instead.

If you set to point to then in that case it would point to your local Apache server.

To create a map, we enter the URL and IP address in the hosts file that lives in the /etc directory.  (ie. /etc/hosts)

To modify the file we will use a text editor called nano.  It is much easier than some of the other options.   The hosts file is protected so we need to run as SUDO.  So get to a terminal (Ctrl+Alt+T in Ubuntu) and run the following command.

#sudo nano /etc/hosts

You then enter your root password and can then add the line. [TAB]

[TAB] is the tab key, not actually the word “[TAB]”


Hit Ctrl+O to save the file and then Ctrl+X to exit.

Now if you go to “” (not because we did not create an entry for that) you should see something like this…


Boom, all done.  Now you’re a hosts file expert.  Make sure to delete that line if you want to use Google again normally.

One thought on “Windows guy learns linux hosts files”

Leave a Reply

Your email address will not be published. Required fields are marked *

+ eight = 13

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>