Oracle Linux

How to Change the Hostname in Oracle Linux 8

When you get a new computer system or install a new virtual machine on an already existing computer system, there will be a default hostname or device name that comes with the system. In Oracle Linux 8, you may change the server hostname according to your preferences. This article shows you the two most effective methods for changing the hostname of an Oracle Linux 8 system.

Methods of Changing the Hostname in Oracle Linux 8

There are two methods that you can use to change the hostname of your Oracle Linux 8 system:

  1. The GUI (Graphical User Interface) Method
  2. The CLI (Command-Line Interface) Method

The following sections show you how to change your server’s hostname using each of these methods.

Method I: The GUI Method

To change the hostname of your Oracle Linux 8 system using the GUI method, perform the following five quick steps.

Step 1: Check Current Hostname

Before attempting to change the hostname of your Oracle Linux 8 system, you should first check the current hostname so that after changing the hostname, you can easily verify whether the changes have taken place. To check the current hostname of your Oracle Linux 8 system, launch the terminal, then execute the following command in the terminal:

$ hostnamectl

The hostnamectl command displays the hostname of your system, as well as some other system-related details, such as information about its architecture, kernel, operating system, and more. The current hostname of my Oracle Linux 8 system is 10.0.2.15, as you can see in the following image:

Step 2: Access System Settings

Now, we will change the hostname that we found in the previous step. For that, we will first need to access the Oracle Linux 8 System Settings. Simply right-click anywhere on your Oracle Linux 8 desktop and select the Settings option from the drop-down menu that appears. This step is highlighted in the following image:

Step 3: Access System Details

After you click on the Settings option from the drop-down menu, the Oracle Linux 8 System Settings window will appear on your screen. Use the scrollbar in the leftmost pane of this window to scroll down and locate the Details tab, as highlighted in the image below. This tab corresponds to the Oracle Linux 8 System Details; simply click on this tab to access the System Details.

Step 4: Change Hostname

When you click on the Details tab in the Oracle Linux 8 System Settings window, you will be able to see all the basic system-related details, such as memory, processor, OS type, etc. Here, you will also see a field that corresponds to the Device Name, as highlighted in the following image. The Device Name is, in fact, the hostname of your Oracle Linux 8 system.

In the text field corresponding to the Device Name tag, type any hostname of your choice. We elected to change our Device Name or hostname from 10.0.2.15 to Aqsa Yasin, as highlighted in the image below. After making these changes, close your Oracle Linux 8 System Settings window and the hostname change should be complete.

Step 5: Verify that Hostname Has Changed

By now, the hostname of our Oracle Linux 8 system should have been changed successfully. However, whenever you attempt to change your system settings, it is always recommended to verify whether the desired changes have taken place. To verify whether the hostname of your Oracle Linux 8 system has been changed, run the following command again:

$ hostnamectl

As you can see in the highlighted part of the output of this command, we have successfully managed to change the hostname of our Oracle Linux 8 system from 10.0.2.15 to Aqsa Yasin. You may choose any other hostname of your choice.

Method II: The Command-Line Method

To change the hostname of your Oracle Linux 8 system using the terminal, perform the following two easy steps.

Step 1: Change Hostname

Before performing this step, you can choose to check your current hostname as we did in Method # 1 using the hostnamectl command. After checking the current hostname, you can change the hostname by running the following command in your Oracle Linux 8 terminal:

$ hostnamectl set-hostname NewHostname

Here, replace NewHostname with whichever name you want to be the new hostname. We changed the hostname to Aqsa, as shown in the image below:

If this command is executed without any errors, then it will not display any messages in the terminal, as shown in the following image:

Step 2: Verify Whether Hostname Has Changed

After changing the hostname of your Oracle Linux 8 system through its terminal, you can now easily verify it by running the following command:

$ hostnamectl

As highlighted in the following image, our Static hostname is now Aqsa, so it has been verified that we have successfully managed to change the hostname of our Oracle Linux 8 system.

Conclusion

In this article, we presented to you both the GUI-based method and the CLI-based method for changing the hostname of your Oracle Linux 8 system. You may choose to follow whichever method is most convenient for you. By following either of these methods, you can change the hostname of your Oracle Linux 8 system as many times as you would like. If you make a mistake while naming your device, you can correct it as soon as you realize it by following the methods provided in this article.

About the author

Aqsa Yasin

I am a self-motivated information technology professional with a passion for writing. I am a technical writer and love to write for all Linux flavors and Windows.