Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm trying to configure a Ubuntu 10.4 server and have a little confusion with configuring with hostnames.

My domain is example.com and the hostname would be one. If I'm correct, when I've configured this properly, typing hostname at the prompt would yield one and hostname --fqdn would yeild one.example.com. Am I right?

Could you tell me what values I would need to put in /etc/hostname and /etc/hosts?

Although a very trivial thing, I haven't been able to configure it to get the desirable output. I'm definitely missing something here.

Thanks everyone.

share|improve this question

1 Answer 1

up vote 4 down vote accepted

In /etc/hostname you have to put the unqualified name for the host; in your example you need to put

one

In /etc/hosts, which is a DNS resolving file, you need to specify which IP address is host one. Let's suppose one has IP address 192.162.1.2, then you have to add this line to your /etc/hosts:

192.168.1.2 one.example.com one

(as stated on man hosts: *IP_address canonical_hostname [aliases...]*).

Hope this helps

EDIT: I forgot: for Ubuntu AFAIK you have to run /etc/init.d/hostname.sh as root after modifying the hostname file. I'm not sure, but that's how it's done in Debian.

share|improve this answer
1  
The init.d script likely just reads /etc/hostname and runs the hostname command. –  grawity Aug 22 '11 at 19:05

Your Answer

 
discard

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.