How to set and change the system hostname on Rocky Linux in a few simple steps.


In a LAN setup, each device is allocated an IP address to differentiate it from others. But remembering each device by its IP address, especially in a large network, can be quite challenging. In such cases, assigning a unique hostname to each device can make the identification process much easier. Additionally, hostnames enable devices to communicate with each other using their respective names instead of IP addresses. This article will guide you on the steps to set and modify the hostname on Rocky Linux. These steps are applicable to both Rocky Linux 8 and Rocky Linux 9 versions.


The following is a list of items needed to follow along this guide:
1) A desktop or laptop with 50GB of free disk space, a dual core processor and 4GB of RAM
2) An SSH client such as Putty
3) Rocky Linux 9.3 or newer
4) A stable internet connection
5) A basic understanding of Linux commands


The following is an overview of the steps covered in this guide:
1) Check the current Rocky Linux hostname
2) Change the Rocky Linux hostname using CLI commands
3) Change the hostname using the /etc/hostname config file
4) Change the hostname using NMTUI
5) Conclusion.

Check the currect Rocky Linux hostname

Prior to configuring a hostname, it is crucial to verify the existing hostname of your system. You can do this by executing the command below:


In the output that appears, you should be able to identify the current hostname of your system which is labeled as “Static hostname”. 

Change the Rocky Linux hostname using CLI commands

The hostname for the system can be changed temporarily or permanently. If you want to temporarily change the hostname to “newhostname,” then you can execute the following command:

hostname newhostname

To change the hostname permanently, you can use the “hostnamectl” command. Here is the syntax you can use to change the hostname permanently:

hostnamectl set-hostname newhostname

Once you execute the above command, you can verify the new hostname by running the following command:


Change the hostname using the /etc/hostname config file

You also change the system hostname by editing the /etc/hostname configuration file. After making the changes, a system restart is necessary to apply the modifications. To alter the hostname, navigate to the /etc/hostname file using a text editor like nano:

nano /etc/hostname

Replace the current hostname with the new desired name:


Save the changes and exit the file, then reboot the system to implement the new hostname:

sudo reboot

Change the hostname using NMTUI

The system hostname can also be changed using the NMTUI command line utility. If the utility is not installed, run the following command to install it:

sudo dnf makecache --refresh
sudo dnf -y install NetworkManager-tui

Once installed, run the following command to open NMTUI:


The tool will open a dialog box where you can opt for the Set system hostname option. Once you have selected it, you will be prompted to type in the new hostname. After doing so, proceed by clicking the OK button to save the new hostname.


There are several ways to set and modify the hostname on Rocky Linux. Choosing the method that best suits your needs depends on your comfort level with command line tools and your preference for graphical interfaces. Regardless of the chosen method, remember to verify the new hostname and, if necessary, reboot the system for the changes to take effect. By using a descriptive hostname, you can significantly improve the organization and manageability of your Rocky Linux network. This concludes our guide on setting and modifying hostnames on Rocky Linux. We hope this information proves valuable in your network administration endeavors.


1. Verify the new hostname after making changes.
2. Reboot the system if necessary for the changes to take effect.

We hope that this tutorial has been very helpful and we would like to thank you for reading it. Please visit the homepage for more helpful guides and tutorials.

Scroll to Top