Change Hostname

Change Hostname CentOS

The /etc/sysconfig/network file contains a BASH variable set with a line like HOSTNAME=localhost.localdomain.

[root@localhost ~]# cat /etc/sysconfig/network | grep HOSTNAME
HOSTNAME=localhost.localdomain

We will want to modify this to the actual hostname. After doing so it is best to reboot the machine in order for it to take affect. The new variable will be sourced during startup and the hostname will be set properly. If you are unable to reboot, you can also use the hostname and domainname commands. You will also want to be sure that the hostname you set matches your IP address in the /etc/hosts file if used, and also in the DNS servers. (listed in /etc/resolv.conf)

(Comments)

Comments