Before You Begin

This tutorial describes how to update the system host name on an Oracle Linux system from the command line. This tutorial is targeted at Oracle Linux 8 users, but the hostnamectl command can be used on other systems where systemd is installed, such as Oracle Linux 7.


Many Oracle Linux systems are installed without a desktop environment. However, multiple ways using command lines are available to configure base system settings, such as the system hostname.

In other distributions, configuring the system hostname typically involves editing system files, such as /etc/hostname and /etc/hosts, running the hostname command to set the hostname, and rebooting the system. With Oracle Linux, the process is simplified through the hostnamectl command.

What Do You Need?

Check the current configuration

To check the current configuration for a system, simply run the hostnamectl command without any parameters, for example:

$ sudo hostnamectl
   Static hostname: localhost.localdomain
Transient hostname:                                                                                                                                                      
         Icon name: computer-server                                                                                                                                                                  
           Chassis: server                                                                                                                                                                           
        Machine ID: f8bef1aa7e2e4d43907bdf49ed297f8c                                                                                                                                                 
           Boot ID: 10b41dcd69f6464294308cf4ef632868
  Operating System: Oracle Linux Server 8.0
       CPE OS Name: cpe:/o:oracle:linux:8:0:server
            Kernel: Linux 4.18.0-80.el8.x86_64
      Architecture: x86-64

The output shows that the system is configured with a Static hostname and a Transient hostname. The Static hostname is the default host name for the system and is configured in the /etc/hostname file. The Transient hostname represents the name that is set for the system by services such as DHCP or mDNS after a system boot. If the Transient hostname is not set, the system uses the Static hostname. The system can also be configured with Pretty hostname, a friendly free-form system name that is displayed in user interface environments. Normally, the Transient hostname and the Pretty hostname are identical. However, with the hostnamectl command, you can set different values for each.

Use the hostnamectl as well to check the Operating System release and update level, including the current kernel version the system uses.

Set the system host name

Type the following command:

$ sudo hostnamectl set-hostname myhost.mydomain

Substitute myhost.mydomain with the value for your system host name and domain.

You can also set different values for each of the static, transient or pretty host name values. For example, you can run:

$ sudo hostnamectl set-hostname --pretty "My Oracle Linux 8 Server"

The changes implemented by the hostnamectl command are effective immediately and do not require a system reboot.

Want to Learn More?