How to Change the Hostname on Linux CentOS 6.2 Server

Share this Article :

In this post, i will show you on how to change the Hostname on linux CentOS 6.2. I have tested this on RHEL 6, CentOS 5.5 and CentOS 6.2. Reboot is required for both options (A) and (B) for the changes to take effect.

Check current hostname with this command :

[[email protected] ~]# hostname --fqd
centos62.ehowstuff.local

Option A:
1. Modify /etc/sysconfig/network

[[email protected] ~]# vi /etc/sysconfig/network

2. Edit to your preferred hostname :

NETWORKING=yes
HOSTNAME=NewHostname.ehowstuff.local

3. Modify /etc/hosts file as below :

[[email protected] ~]# vi /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

192.168.1.44 NewHostname.ehowstuff.local NewHostname

4. Save and reboot your server.

Option B:
1. Type the following command to enter GUI mode.

[[email protected] ~]# system-config-network

2. Go to “DNS Configuration”.
Hostname

3. Modify your preferred hostname and click OK.
Hostname

4. Click ” Save & Quit”.
Hostname

5. Modify /etc/hosts file as below :

[[email protected] ~]# vi /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

192.168.1.44 NewHostname.ehowstuff.local NewHostname

6.Reboot your server.

2 Comments

  1. James
    • James

Leave a Reply