This tutorial explains how to set or the change hostname from the command line on your Linux server. The hostname is also often referred to as a
Fully Qualified Domain Name (FQDN hostname).
1. Display hostname.
Use the following command to display your server hostname.
You can add the
-f flag stands for
full, because in some cases only a part of the actual hostname may be visible.
2. Set a new hostname.
hostnamectl set-hostname <new_hostname>
3. Other methods.
If none of the above examples work, you can edit the
/etc/hostname file and the
/etc/hosts file and replace the default occurrences of the
hostname with the correct one.