User Tools

Site Tools


Change HostName

Apr 2023

To change the hostname of an Alma Linux instance, use the following procedure.

First, check the current hostname: from the console enter:


This will give an output similar to below:

   Static hostname: localhost.localdomain
         Icon name: computer-server
           Chassis: server
        Machine ID: 87b77afdf05948d88282bb44dc1e8386
           Boot ID: a7c17a79aa394c2f84758fa133c735cb
  Operating System: AlmaLinux 8.5 (Arctic Sphynx)
       CPE OS Name: cpe:/o:almalinux:almalinux:8::baseos
            Kernel: Linux 4.18.0-348.el8.x86_64
      Architecture: x86-64

In this example we can see that the hostname is the default value of localhost.localdomain and we want to change this to something that we can use and recognise.

To set the hostname use the following:

  hostnamectl set-hostname 'your-hostname'

For example, lets say I want to change the hostname to be mailsvr, then I would use:

  hostnamectl set-hostname mailsvr

We can now check the hostname from the console again using:


The hostname returned will now be the one you set (mailsvr) in this example.

We also need to edit the following file:


Add a line at the end of the file with your Alma Linux IP and the hostname you just used:   controller localhost.localdomain localhost4 localhost4.localdomain4
::1         controller localhost.localdomain localhost6 localhost6.localdomain6    mailsvr

Now reboot the Alma Linux instance.

When you log back in, you should see your command prompt now contains your hostname:

  [root@mailsvr /]#

Hostname setting is complete.

change_host_name.txt · Last modified: 2023/04/03 07:08 by walkeradmin