To change the hostname on CentOS Linux 5/6, you can use the hostname command and the /etc/sysconfig/network file.
hostname command with the desired hostname:sudo hostname newhostname
Replace newhostname with the actual hostname that you want to use.
/etc/sysconfig/network file and change the HOSTNAME value to the desired hostname. For example:sudo nano /etc/sysconfig/network
HOSTNAME=newhostname
Replace newhostname with the actual hostname that you want to use.
Save and close the /etc/sysconfig/network file.
Restart the network service to apply the changes:
sudo service network restart
After completing these steps, the hostname should be changed to the new value. You may need to log out and log back in for the changes to take effect.
Note: Changing the hostname may affect the behavior of some services, such as DNS and email. Be sure to test your applications and services after changing the hostname to ensure that they are functioning as expected.