This article will cover the simple steps to change hostname in CentOS. Some software such as CPanel require a valid Fully Qualified Domain Name for the hostname to be used during their installation.
There are 4 easy steps to change hostname:
Login to your server as a root user.
Change your hostname to a different name of your choice, For example:
hostname srever.cpanelplesk.com
To change your hostname edit the /etc/hosts file with your favorite text editor. For example:
nano /etc/hosts
Replace your old hostanme with the new one, Save the file and exit the editor.
Now edit /etc/sysconfig/network file, This file also contain your hostname.
Change the old hostname with your desired one and save the file.
Restart the network service:
service network restart
Run the following command to check your new hostname:
hostname
The new hostname will be displayed in your ssh terminal.