How to Change the Server Hostname on CentOS ?

This article will show you how to change the dedicated server hostname on CentOS. There are two ways through which you can be able to change server hostname.

The first process by which you can change the server hostname is by using the “Hostname command”.

Enter the below command into the console:

hostname my.server.com

By using the above command, the server hostname will gets changed automatically.

OR

you have to change the server hostname using the “Editing network file”.

Into the console enter the command as follow:

vi /etc/sysconfig/network

After entering the command you will see something like this:

NETWORKING=”yes”
GATEWAY=”192.0.2.2″
HOSTNAME=”some.servername.com”

Simply, change your “hostname” there and you are completed with it. I hope it will help you.