How to set/change FQDN on Ubuntu 20.04 Linux
In Ubuntu 20.04, you can set or change the Fully Qualified Domain Name (FQDN) by following these steps:
- First, open the
/etc/hostsfile by running the following command:
sudo nano /etc/hosts- Locate the line that starts with
127.0.0.1and change the hostname to your desired FQDN, for example:
127.0.0.1 localhost.localdomain mynewfqdn- Next, you will need to change the hostname in the
/etc/hostnamefile by running the following command:
sudo nano /etc/hostnameIn the file, change the hostname to your new desired FQDNrn
- Now, you need to tell the running system to update the hostname by running the following command:
sudo hostnamectl set-hostname mynewfqdn- Finally, you will need to reboot your machine for the changes to take effect.
- You can also use the
hostnamectlcommand to check the current hostname, for examplehostnamectl status.
It's also important to make sure that the FQDN is properly set up in your DNS server, so that other machines are able to resolve it.
