Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

2 Answers 2

up vote 96 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 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.