How to set/change FQDN on Ubuntu 22.04

--

A static hostname for the Ubuntu box is always set in the /etc/hostname file. Use the cat command to display it:

cat /etc/hostname

Of course, we can use a text editor to modify the file but the recommended way is to use the hostnamectl command to edit /etc/hostname file. The syntax is:

sudo hostnamectl set-hostname only-host
hostnamectl set-hostname host.your-fqdn-here

Now check /etc/hosts should have your host.your-fqdn appened in the 127.0.0.1 line if not then manually append:

sudo nano /etc/hosts

After this it should look like this.

--

--

Chandan Kumar Mandal
Chandan Kumar Mandal

No responses yet