How to configure server hostname in Red Hat Linux Enterprise Server

Share this:

In RHEL (Red Hat Enterprise Linux) the administrator has several methods to define the server name. By default, the Linux has a static host name which is defined in the /etc/hostname file, there is also the transient hostname which is a name that is dynamic and it is maintained by the kernel, and it can be changed during execution by network services, such as DHCP.

Solution


The first step is to identify the current server name, and we can do that by running the following command on the terminal.

hostname

Method 01 – Using hostname

The most orthodox method is editing the file hostname located on the /etc

image

We can use any text editor (I’m using vi), and on the first line we can identify the server name.

image

Method 02 – Using the Network Manager Text User Interface (TUI)

It is similar to the old format to install Red Hat, in the terminal type in nmtui and on the new menu, select Set System hostname

image

Type in the hostname of the server and click on OK and confirm all subsequent window.

image

 

Method 03 – Using hostnamectl

Another method is using the hostnamectl and we can use the following command to retrieve the information about the static, transient and icon name of the computer.

hostnamectl status

In order to change the hostname we can use 
hostnamectl set-hostname servername.domain.ca
image

Method 04 – Using Network Manager CLI (Command Line Interface)

Another possible method is using the command line interface of network manager to change the static hostname.  To check the current server name you can use:
nmcli general hostname
To change the hostname, use the following command
nmcli general hostname servername.domain.ca
image

Refreshing the settings…

When changing the static hostname, in some cases it is required to refresh the settings, and we can do that by running the following command. 
systemctl restart systemd-hostnamed

Written by Anderson Patricio

Anderson Patricio

Anderson Patricio is a Canadian MVP in Cloud and Datacenter Management, and Office Server and Services, besides the Microsoft Award he also holds a Solutions Master (MCSM) in Exchange and several other certifications. Anderson has been contributing to the Microsoft Community with articles, tutorials, blog posts, twitter, forums and book reviews. He is a regular contributor here at ITPROCentral.com, MSExchange.org, Techgenix.com and Anderson Patricio.org (Portuguese).

Related Post

Installing Red Hat Enterprise Linux 7.3 We are going over the process to install Red Hat Enterprise Linux. We created a new VM in our Hyper-V environment and we will install the Red Hat Ente...
Managing network settings on Red Hat Enterprise Li... By default in Red Hat Enterprise Linux 7.3 (the version which this article was written) the default network service is done by NetworkManager which is...