To set or change the fully qualified domain name (FQDN) on Ubuntu 20.04, follow these steps:
/etc/hostname
file and set the hostname to the desired FQDN. For example:sudo nano /etc/hostname
server1.example.com
/etc/hosts
file and set the FQDN as the first entry for the localhost address (127.0.0.1
). For example:sudo nano /etc/hosts
127.0.0.1 server1.example.com server1 localhost
Save and close the file.
Reboot the system to apply the changes:
sudo reboot
After the system has restarted, the FQDN should be set to the new value. You can use the hostname
command to verify the current FQDN:
hostname -f
This will display the FQDN of the system.