Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This may be a bit of a noobish question, but I was taking a look at /etc/hosts on my new Xubuntu install and saw this: localhost myhostname

On most 'nixes I've used, the second line is omitted, and if I want to add my hostname to the hosts file, I'd just do this: localhost myhostname

Is there a difference between these two files in any practical sense?

share|improve this question
up vote 111 down vote accepted

There isn't a great deal of difference between the two; 127/8 (eg: => are all bound to the loopback interface.

The reason why is documented in the Debian manual here:

Ultimately, it is a bug workaround; the original report is here:

share|improve this answer
Exactly what I was looking for, thanks! – Tom Feb 23 '12 at 18:27
The actual reason: "Associating the system hostname with the latter had the unwanted effect of making 'localhost.localdomain' the canonical hostname associated with the system hostname. That is, 'hostname --fqdn' returned 'localhost.localdomain'." – cmroanirgo May 29 '15 at 20:58

To sum up the linked-to information:

  • It is (debatably) useful to have an entry in your /etc/hosts translating the machine's fully-qualified domain name into its permanent IP address.
  • debian-installer, and more specifically, its netcfg component, currently (up to March 2013 at least) creates this entry.
  • If the machine is not known to have a permanent IP address, the debian-installer still wants it to have that kind of entry.
  • The address uses the loopback interface, answered by your own machine, just like but is a distinct entry in /etc/hosts which can be considered separately from if/when necessary.

Thomas Hood explains adding this entry as follows:

[This] will ensure that if the UNIX hostname is resolved then it will always be its own canonical hostname


In the long run the UNIX hostname should not be put in /etc/hosts at all.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.