How to Change Hostname on CentOS 5.8

by skytech on April 23, 2012

In this post, i will show you the basic guides on how to change the hostname on linux CentOS 5.8 server. Assumed that you have root account access on this CentOS server and this steps may working on RHEL 6, RHEl 5, CentOS 5.5, CentOS 5.6, CentOS 5.7, CentOS 6.0, CentOS 6.1 and CentOS 6.2.

1. Check current hostname :

[root@localhost ~]# hostname

2. Modify “/etc/sysconfig/network” to change hostname :

[root@localhost ~]# vi /etc/sysconfig/network

Change the hostname to the following :


Alternatively, you can execute the following command :

[root@localhost ~]# hostname centos58.ehowtuff.local

3. Change host file :

[root@localhost ~]# vi /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.               localhost.localdomain localhost
::1             localhost6.localdomain6 localhost6 centos58.ehowstuff.local centos58

4. Reboot the server.

[root@localhost ~]# reboot

As always if you need any help you can reach us on twitter @ehowstuff or drop us a comment below. Jumping through archives page to read more articles..

Previous post:

Next post: