How to Set HostName in Linux RHEL 7/ Centos 7

We can change a hostname directly using the below commands.

  • hostnamectl

  • nmtui

  • nmcli

Hostnamectl

We can assign three types of names in RHEL 7/ Centos 7. They are given below

  1. Pretty

  2. Transient

  3. Static

Before VM Status Check:

Static.

It’s a permanent name for the host.

After VM Status Check

Pretty

It’s used to set the name which contains limited special characters

Before VM Status Check:

After VM Status Check

Transient

We can use it as a temporary name whenever we exit the session this name will gone.

VM Status Check

NMTUI Command

Setup Hostname Using nmtui Command

Once hit the command pop-up configuration will be open and changed server name.

Setup Hostname Using nmcli Command