Saturday, September 23, 2017

How to change host name in CentOS

# cat /etc/hosts
127.0.0.1               localhost.localdomain localhost
::1             localhost6.localdomain6 localhost6

# cat /etc/sysconfig/network
NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=localhost
NTPSERVERARGS=iburst

# hostname
localhost.localdomain

just edit following method


# vi /etc/hosts
127.0.0.1               changename
::1             localhost6.localdomain6 localhost6


# vi /etc/sysconfig/network
HOSTNAME=CHANGENAME


#reboot

now you can get the changed name


in case fo EC2

#hostnamectl set-hostname yourhostname

# vi /etc/cloud/cloud.cfg
//add following line to bottom of the file

preserve_hostname: true

#reboot

No comments:

Post a Comment