Setting Fully Qualified Domain Name (FQDN) in Ubuntu

In Ubuntu, open a terminal window.  Log into terminal as your username.  Enter your password when requested.  Switch to the root super user as follows:

sudo -s (enter)
input your password when requested (enter)

Change to the /etc directory as follows:

cd /etc

The ‘hostname’ file will contain your short hostname, such as mx1.

Check the current hostname by entering the hostname command, and the hostname might be something like ‘mx1’ — as follows:

hostname (enter)

Your fully qualified domain hostname should be something like  Check the current FQDN hostname with the -f option, as follows:

hostname -f (enter)

The ‘hosts’ file should be edited to insert your FQDN as well.  Using the PICO text editor, open the hosts file to be edited as follows:

pico hosts (enter)

Change the second line of the hosts file from this:    localhost     mx1

To this:    localhost     mx1

Then save the hosts file as follows:
hosts (enter)

Now check the fully qualified domain hostname, as follows:

hostname -f (enter)

Check the hostname, which should still be ‘mx1’


Escape from the terminal window:

Exit (enter)

Exit (enter)

Print Friendly, PDF & Email