How to Set Hostname on CentOS (RHEL)
To temporarily set the host name of centos, use hostname command.
However, once the server is rebooted, the hostname will revert to it's previous setting.To permanently change the hostname, you need to edit the network file at /etc/sysconfig/network.
where <value> should be the Fully Qualified Domain Name (FQDN), such as hostname.expample.com, but can be whatever hostname is necessary.
You can also edit /etc/hosts:
127.0.0.1 myhostname localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 myhostname localhost localhost.localdomain localhost6 localhost6.localdomain6