Change Linux Server Hostname

Applies to CentOS 7, OEL 7 and RedHat.

Edit network file

Open /etc/sysconfig/network and change hostname in the file.

Edit hosts file

Open /etc/hosts and change the hostname in the file

Run hostnamectl

The hostnamectl command is used to change the server hostname

# hostname
# hostnamectl set-hostname
# hostname

Restart network

We need to restart the server network to make change permanent

# /etc/init.d/network restart

Logout from the server and login again. You should see new hostname!

Was this article helpful?

Related Articles

Leave a Comment