CentOS Linux 5/6 Change Hostname Command

www.‮ttual‬uri.com
CentOS Linux 5/6 Change Hostname Command

To change the hostname on CentOS Linux 5/6, you can use the hostname command and the /etc/sysconfig/network file.

  1. To change the hostname temporarily (until the next reboot), use the hostname command with the desired hostname:
sudo hostname newhostname

Replace newhostname with the actual hostname that you want to use.

  1. To change the hostname permanently, edit the /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.

  1. Save and close the /etc/sysconfig/network file.

  2. 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.

Created Time:2017-10-16 14:38:40  Author:lautturi