Home » DB Install » How to Change Hostname on RHEL 7 (Red Hat Enterprise Linux)

How to Change Hostname on RHEL 7 (Red Hat Enterprise Linux)

The hostname is known as the system’s identifier, which is set at the time when we are installing the Red Hat Linux operating system.

This tutorial will explain setting the hostname for your system or virtual machine after RHEL 7 installation.

Prerequisites

Before going through with this tutorial, make sure your system has RHEL 7 Linux installed and have user access with sudo privileges to execute administrative commands.

Display the Current Hostname

To check the current hostname on the Red Hat Operating system, use the hostnamectl command as shown below:

$ hostnamectl
 Static hostname : satishsystem
       Icon name : satish-vm
         Chassis : vm
      Machine ID : 6f17445f53074505a008c9abd8ed64a5
         Boot ID : 1c769ab73b924a188c5caeaf8c72e0f4
  Virtualization : kvm
Operating System : rhel 7
          Kernel : Linux 4.15.0-22-generic
    Architecture : x86-64

You can see in the above output; the current hostname is set to the satishsystem.

Change the Hostname

To set the new hostname for your RHEL 7 system, use the following steps.

Method 1 – Change hostname using hostnamectl command.

You can change the hostname in RHEL 7 using the hostnamectl command.

For example, we can change the system static hostname to linuxconcept by using the following command:

$ sudo hostnamectl set-hostname linuxconcept

The command hostnamectl does not return any output on success. It returns 0 on success or failure code on failure results.

Method 2 – Change hostname using nmtui command

The command nmtui provide the user interface for NetworkManager, which we can use to configure many things related to Networking, including hostname.

You can start NetworkManager using nmtui command, as shown below:

$ sudo nmtui

When you get the GUI of NetworkManager, navigate and select Set system hostname option using arrow keys:

  • Facebook
  • Twitter
  • reddit
  • LinkedIn

Now, set your new hostname:

  • Facebook
  • Twitter
  • reddit
  • LinkedIn

Hit Enter button to confirm new hostname changes:

  • Facebook
  • Twitter
  • reddit
  • LinkedIn

After setting the hostname restart the system-hostnamed service to take new hostname affected, as shown below:

$ sudo systemctl restart systemd-hostnamed

Method 3 – Change Hostname using nmcli command

You can use nmcli command in the place of nmtui command; the only difference is nmtui provides you GUI interface, and nmcli offer you with the command-line interface for NetworkManager.

As you know, we are not using GUI interface on Server operating system, so nmcli is an essential command to configure network including hostname on servers.

You can use the nmcli command to check the current hostname, as shown below:

$ sudo nmcli general hostname

You can use nmcli command to change the hostname, as shown below, we are changing the hostname to host.linuxconcept.com:

$ sudo nmcli general hostname host.linuxconcept.com

After changing the hostname only need to restart system-hostnamed service to take new hostname affected, as shown below:

$ sudo systemctl restart systemd-hostnamed

Verify new hostname after change

You can verify the hostname has changed in your Red Hat Operating system by checking hostname using the hostnamectl command, as shown below:

$ hostnamectl

You will get your new hostname on the output screen.

 Static hostname : host.linuxconcept.com
       Icon name : satish-vm
         Chassis : vm
      Machine ID : 6f17445f53074505a008c9abd8ed64a5
         Boot ID : 1c769ab73b924a188c5caeaf8c72e0f4
  Virtualization : kvm
Operating System : rhel 7
          Kernel : Linux 4.15.0-22-generic
    Architecture : x86-64

Conclusion

Now, you have learned to change the hostname for your installed RHEL 7 Linux server or system without restarting the system.

If you get any problem with changing the hostname of your system, please leave a comment below.

Related Posts

How to Install MongoDB on RHEL 8 Linux

How to Install MongoDB on RHEL 8 Linux

MongoDB is an open-source and free NoSQL document based database system. Nowadays, it is prevalent as most application developers are using MongoDB, which can handle big data. As a MongoDB is a NoSQL database, It stores data in JSON-like documents where fields can...

How to Install Python 3 on RHEL 8 (Red Hat Enterprise Linux)

How to Install Python 3 on RHEL 8 (Red Hat Enterprise Linux)

Python is one of the most popular and easy to code programming language nowadays, because of its simplicity and easy to code. It is now very popular among beginners and experienced computer programmers or developers. It is use to develop any kinds of...

How to Install MongoDB on RHEL 7 Linux

How to Install MongoDB on RHEL 7 Linux

MongoDB is an open-source and free NoSQL document based database system. Nowadays, it is prevalent as most application developers are using MongoDB, which can handle big data. As a MongoDB is a NoSQL database, It stores data in JSON-like documents where fields can...

How to Install OpenCV on RHEL 8 (Red Hat Enterprise Linux)

How to Install OpenCV on RHEL 8 (Red Hat Enterprise Linux)

OpenCV (Open Source Computer Vision Library) is an open-source computer vision and machine learning software library. OpenCV was built to provide a common infrastructure for computer vision applications and to accelerate the use of machine perception in commercial...

Follow Us

Our Communities

More on Redhat

The Ultimate Managed Hosting Platform
Load WordPress Sites in as fast as 37ms!

0 Comments

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

20 − 9 =

Shares