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:

  1. First, open the /etc/hosts file by running the following command:
sudo nano /etc/hosts
  1. 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
  1. 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

  1. Now, you need to tell the running system to update the hostname by running the following command:
sudo hostnamectl set-hostname mynewfqdn
  1. Finally, you will need to reboot your machine for the changes to take effect.
  2. You can also use the hostnamectl command to check the current hostname, for example hostnamectl 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.

Leave a Comment