This quick tutorial will describe how to change the hostname on your CentOS Linux server.
Where HOST_NAME occurs, replace it with your desired hostname.
1. Run the hostname command:
hostname HOST_NAME
2. Open /etc/sysconfig/network, update the HOSTNAME line and save:
# vim /etc/sysconfig/network HOSTNAME=HOST_NAME
3. Open your hosts file, and update the hostname entry and save:
# vim /etc/hosts 127.0.0.1 HOST_NAME
Alternatively, you can use this script to update your hostname.