How Do You Permanently Change the Hostname of a Linux CentOS Server?

Problem scenario:  You edited the /etc/hosts file and the /etc/sysconfig/network file to have a new hostname. You used the "hostname newHostname" command (where newHostname is the desired new host name). You rebooted the server and the hostname is still localhost.localdomain. How do you configure the host name to be different?

Solution
None of the above steps were necessary for changing the hostname for the purposes of having the "hostname" command return a new hostname.  The above steps by themselves would not change the hostname that you see on the command prompt either.  To change the hostname for the "hostname" command to return the new hostname, and to have the character prompts reflect a new hostname, do this:

1.  Modify /etc/hostname to the desired new hostname.
2.  Save the file.
3.  Reboot for the hostname on the character prompts to reflect the new hostname.

Leave a comment

Your email address will not be published. Required fields are marked *