Hostname in Ubuntu 18.04 & 20.04
You can find and change the hostname with the commands hostname or hostnamectl in Ubuntu 18.04 & 20.04, if you run the command on its own it will tell you what the current name is, the example below is named racknerd-la
[email protected]:~# hostnamectl Static hostname: racknerd-la Icon name: computer-vm Chassis: vm Machine ID: 38db1f2160cc4dad9a4a1999bdf332a91 Boot ID: 477dac72e3694ab6a0aabb070f8f2110 Virtualization: kvm Operating System: Ubuntu 18.04.4 LTS Kernel: Linux 4.15.0-106-generic Architecture: x86-64
To change the hostname use hostnamectl set-hostname
hostnamectl set-hostname newhostname
This will change the hostname, verify by running hostnamectl or hostname command.
Fully Qualified Domain Name (FQDN) in Ubuntu 18.04
Yo see the fully qualified domain name run
To change it you need to change the domain in /etc/hosts in the example below…
127.0.0.1 localhost localhost.localdomain ::1 localhost localhost.localdomain 126.96.36.199 racknerd-la.wpbeaches.com racknerd-la
The domain name is marked followed by the hostname, it happens to be a subdomain name with the the same name as the hostname ‘racknerd-la’ just change the domain name and test hostname –fqdn again to verify.
Fully Qualified Domain Name (FQDN) in Ubuntu 20.04
hostnamectl set-hostname your.hostname.com
Domain Name now should also be correct, verify it…
To add a reverse dns entry to the fully qualified domain name I find that most VPS providers will have an option via their control panels to set this or a support ticket needs to be raised.