How to change Centos Hostname server

Every server is started with the server’s given name as the hostname. Sometimes when the server host some  softwares, such as cPanel, that requires a valid Fully Qualified Domain Name (FQDN) for the hostname to be used during their licensing verification system. So its important to set the FQDN hostname for your server .

Change a server’s hostname

First you have to Login to your server using root username privileges and edit the file /etc/sysconfig/network by running the following command

vi /etc/sysconfig/network

then you have to change HOSTNAME= value to your FQDN hostname for example:

Now you need to change the Hostname in the file hosts ,that file used for internal network mapping IPs by running the command

vi /etc/hosts

the new values of the content file should be localhost localhost.localdomain       yourserver

Now you can run the hostname command. This command change the hostname on the server that the command line remembers, but it does not actively update all programs that are running under the old hostname.


Also you need to restart networking on your server to check that changes will persist on restart.

/etc/init.d/network restart


 2,344 total views,  2 views today

Leave a Reply

Your email address will not be published. Required fields are marked *