Install Config Wiki

All about installing, configuring and troubleshooting

User Tools

Site Tools


Configuring the Ubuntu Server Hostname and Host Domain

Published: July 3, 2023 and last edited July 3, 2023

To check the server's current hostname, run this command:

hostname -f

To change the hostname for your server, open the file /etc/hostname in your editor:

sudo vim /etc/hostname

Edit or delete the current hostname and replace it with your hostname. In this 'hostname' file, enter the hostname only, not the entire Fully Qualified Domain Name (“FQDN”). For example, if your FQDN is, enter server1 in this file. After editing, then save the 'hostname' file and exit the editor.

You can add both the hostname and FQDN in the /etc/hosts file:

sudo vim /etc/hosts

Modify the line that starts with to use your FQDN and hostname, in that order:

/etc/hosts	localhost hostname

Remember to replace hostname with your server's hostname, and replace with your own hostname and domain name. Save the 'host' file and exit the editor.

To check whether these names have been changed correctly, reboot the server.

sudo reboot now

While the server is rebooting, you can add an 'A' record for your to your primary DNS server. On a Windows DNS server, select the forward zone for and then add an 'A' record for your hostname in that zone, and the hostname will be prepended to the domain name of the selected zone. Close the DNS.

Next, ssh into your server again. You should see the new hostname on your terminal prompt. For example:


Use the hostname command to verify that the FQDN was set correctly:

hostname -f

You should see your FQDN in the output:

If not, then rinse and repeat (including the server reboot)

configuring_ubuntu_hostname_host_domain.txt · Last modified: 2023/07/03 15:33 by wikiadmin