In this guide I will show you how to set or change the hostname on CentOS 8.

The hostname is set during the installation of the operating system or assigned to the virtual machine when it is built.

Displaying the current hostname

To display the current hostname, type any one of the following commands:

# hostname

or

# hostnamectl

Changing the Hostname

In all Linux distributions that are using systemd, you can change the system hostname with the hostnamectl command.

# sudo hostnamectl set-hostname unihost.com

Now check hostnamectl output.

As you can see the hostname has been successfully changed.