User Feedback – /etc/hosts explained : Ubuntu (5.10 / 6.06.1 / 6.10)

By | 2006/12/05

One of you contacted me recently with a few questions regarding my previous post, Network File System (NFS) : Ubuntu (6.06.1 / 6.10). I wanted to post some follow up information on that to help clarify a few of the steps. Some of this may be very simple for many of you, for others it will hopefully open your eyes to a few more powerful aspects of an Ubuntu Linux system. Here goes.

Question: How did you modify the /etc/hosts file to use the ‘media’ shortcut?

Editing the /etc/hosts file is really simple and you can do quite a bit with it. Ever wish you could simple visit “mysite” in your browser and it’d know where you wanted to go? Ever wish you could give nicknames to your local network machines instead of trying to remember the IP address? Here is the place to do it.

To edit the file you would want to use a quick command within a terminal:

sudo gedit /etc/hosts

Simply add a line to your /etc/hosts file to create a network shortcut using the following syntax: ip.address shortcut. Example (on my network): localhost notebook.local notebook media silverbox blackbox

# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

The three lines in italics are my additions. You can use the same syntax to update your /etc/hosts file and go wherever you want! The above is an example of using a shortcut for the local network but the same goes for the outside world. Try something like: 42 bestsiteever

…and the next time you type “42” in your browser it’ll come right up with google (yes, the answer to life, the universe and everything!), or put in “bestsiteever” and come right back here for some more great tutorials!

One thought on “User Feedback – /etc/hosts explained : Ubuntu (5.10 / 6.06.1 / 6.10)

  1. Maarten


    One question though…
    after a reboot, my /etc/hosts file is back to default, without my additions.
    Any ideas how to make additions to /etc/hosts permanent ?

    Thank you in advance,

Comments are closed.