How to change FQDN ( domain name ) on Ubuntu 20.04 Focal Fossa Linux - LinuxConfig.org

In this tutorial you will learn how to set / change server's Fully Qualified Domain Name (FQDN) on Ubuntu Ubuntu 20.04 Focal Fossa Linux server or desktop
This is a companion discussion topic for the original entry at https://linuxconfig.org/how-to-change-fqdn-domain-name-on-ubuntu-20-04-focal-fossa-linux

Hi :slight_smile:

I try to obtain Hostname and Domain Name from DHCP in Ubuntu 20.04. Both settings are in the lease (dhclient.lease) as
option host-name “machine”;
option domain-name “example[dot]org”;

Unfortunately I got only the hostname by executing “hostname -f”

Hi BrassPeddler,

Welcome to our forums.

Try setting your hostname in /etc/hostname to localhost, and reboot.

Hi,
I was following these steps but after adding my IP, my domain, and my hostname to /etc/hosts, hostname --fqdn still prints just my hostname and dnsdomainname still prints nothing. Any ideas?
Running latest ubuntu server release.

Hi Shawnsg,

Welcome to our forums.

The changes will only be visible for new sessions, so If you log out and log back in, you should see the changes taking effect, if all settings where correct.

For the latest releases you can also use hostnamectl to get and set your host’s name.