How to change HOSTNAME in Linux ( CentOS6 / RHEL6 )

Hostname in Linux helps to identify the computer by name over network. When installing operating system hostname will set to default name. We can change the hostname later by changing configuration files.

We can check the current hostname by a command 


[fedo@localhost ~]$ hostname
localhost.localdomain


By editing "HOSTNAME" field in /etc/sysconfig/network file we can change the hostname.

default configuration 

[fedo@localhost ~]$ cat /etc/sysconfig/network
NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=localhost.localdomain
NTPSERVERARGS=iburst

To edit this file we need root permission. So change from normal user to root user using su command and open the file using vim or your favourite editor and change the HOSTNAME field.

[root@localhost fedo]# cat /etc/sysconfig/network
NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=centos89
NTPSERVERARGS=iburst

I updated the hostname to centos89

reboot the computer then login and check the hostname.

[fedo@centos89 ~]$ hostname
centos89

Now you can see the hostname changed to centos89.

!!!

Operating System Used : CentOS release 6.5 (Final)




No comments:

Post a Comment