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

I just signed up for a VPS with Linode, and am going through the beginners' setup instructions, but am a bit lost with the editing for /etc/hosts. It suggests that I edit it as follows (where is my server's ip):        localhost.localdomain        localhost     something

the file currently reads: localhost

# The following lines are desirable for IPv6 capable hosts

First of all, does it matter which of the two localhost lines I use?

Secondly, I don't understand the purpose of the second line - Since the first refers to an IP of, I assume these are local addresses, so why would my server's address be of any consequence? Also, I don't presently want any subdomains - should I not include this line, or change it to something else? Does this affect the DNS connection between my domain name and the server?

I'm rather new at this, so I apologize in advance for any silly questions, and thank you for any help you can offer.

share|improve this question
up vote 1 down vote accepted

The first line is the loopback, that is, referring back to your own server. This is intrinsic to every computer system.

The second line is to establish which IP the server has been assigned, and which domain the server should serve.

You want to have both lines in the file. You can even have more lines similar to the second one, one for each domain being served.

share|improve this answer
So if I don't want a subdomain, should the line read (That is, with a www). Also, does it need an alias and, if so, does it matter what it is? – wyatt Aug 25 '10 at 6:51
I think I may have misunderstood this - is the leftmost part of the FQDN not a subdomain at all, but the name of the machine in question? If so, does it matter at all what I call it? – wyatt Aug 25 '10 at 7:07

In the /etc/host the format of each entry is:

[internet address] [domain name] [alias]

  • internet address - a standard IP address, i.e.
  • domain name - A Fully Qualified Domain Name, FQDN, i.e.
  • alias - this field is optional, i.e. localhost

the first line of your host file that refers to could be modified also like this : localhost

the other line that you set in this file have precedence in DNS resolution,your server before query a DNS Server look at this file /etc/host for resolve FQDN in IP address, therefore edit carefully this file.

share|improve this answer

Aleroot's answer is mostly correct, with the minor correction that the file name is /etc/hosts.

Please also be aware there is a file /etc/host.conf on most modern Linux systems I have seen which controls the order by which a domain name is resolved; the defaults I have seen are


where the hosts file is used before any DNS lookup. Thus, it is important to be careful what hosts you put in /etc/hosts, as they will never look at DNS.

As an example, I've seen it where someone puts an entry for host FOO in the /etc/hosts file. Some months or years later when DNS is changed for FOO they wonder why said machine can't reach FOO. The problem was the hardcoded entry in /etc/hosts.

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.