How to set FQDN in Ubuntu

Posted June 1, 2013 111.2k views
Hi all, I want to set my FQDN in the format I thought I only had to edit /etc/hosts: $ cat /etc/hosts localhost apple # 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 $ I added just this line: 12.345.6.78 apple and then $ reboot and in Domains added an A record for but it does not seem to have any effect - I still get: $ hostname --fqdn localhost $ Any ideas please what I am doing wrong? Thanks...

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
7 answers
What do you have in /etc/hostname?
@ Kamal Nasser

$ cat /etc/hostname

Edit /etc/hostname and put in it. Run hostname -F /etc/hostname and try hostname --fqdn again.
Got it. Providing details for others.

I set hostname in web-interface as `` for new droplet.

It added line in `/etc/hosts` file as: localhost do

I changed it to localhost do is IP of my new droplet.

Now hostname -f work as expected.
@ Kamal Nasser - ok it works now, thank you :)
@Kamal I am facing same issue but given solution is not working for me.

# cat /etc/hosts localhost do

# cat /etc/hostname

# hostname -F /etc/hostname

# hostname

#hostname --fqdn

I am on Ubuntu 12.04 :|