In Ubuntu 20.04, you can set or change the Fully Qualified Domain Name (FQDN) by following these steps:
- First, open the
/etc/hosts
file by running the following command:
sudo nano /etc/hosts
- Locate the line that starts with
127.0.0.1
and 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/hostname
file by running the following command:
sudo nano /etc/hostname
In the file, change the hostname to your new desired FQDN
- 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
hostnamectl
command to check the current hostname, for examplehostnamectl status
.
It’s important to keep in mind that the changes will only take effect after reboot the machine. Also, note that some applications may have hardcoded the old hostname, and will not work until they are updated or reconfigured.
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.