How to Change Hostname on CentOS 5.8

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
localhost.localdomain

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

[root@localhost ~]# vi /etc/sysconfig/network
NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=localhost.localdomain

Change the hostname to the following :

NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=centos58.ehowtuff.local

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.
127.0.0.1               localhost.localdomain localhost
::1             localhost6.localdomain6 localhost6

127.0.0.1 centos58.ehowstuff.local centos58

4. Reboot the server.

[root@localhost ~]# reboot
Leave a Reply

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

SiteGround.com

A world leading hosting company that provides fully-managed innovative and secure solutions, suitable for hosting small to medium-sized websites

Built on the best available technologies combined with Google Cloud for strong redundancy and application availability. Backed by skilled experts to address web security threats, a devops team to create advanced custom security solutions, and 24/7 sysadmins to watch over the platform. This powerful, hands-on approach makes your sites faster, safer, and easier to manage. Starting from only $3.95/mo.

TRY FREE

* up to 30 days money back guarantee