How to set FQDN in Ubuntu

  • Posted on June 1, 2013
  • jr5689Asked by jr5689

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?


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Got it. Providing details for others. <br> <br>I set hostname in web-interface as for new droplet. <br> <br>It added line in /etc/hosts file as: <br> <br> localhost do <br> <br>I changed it to <br> localhost <br> do <br> <br> is IP of my new droplet. <br> <br>Now hostname -f work as expected.

Great! :]

@Kamal I am facing same issue but given solution is not working for me. <br> <br># cat /etc/hosts <br> localhost do <br> <br># cat /etc/hostname <br> <br> <br># hostname -F /etc/hostname <br> <br># hostname
<br> <br> <br>#hostname --fqdn <br>localhost <br> <br>I am on Ubuntu 12.04 :|