Want to rename the hostname of a unix host.
Current name: wagga01.example1111.com
New Name: wagga01.example.com
Make sure that the HOSTNAME entry under /etc/sysconfig/network is updated to new name and reboot the machine and it is done.
Steps are below:
[root@wagga01 ~]# cat /etc/hosts
10.0.2.15 wagga01.example1111.com wagga01 # Added by NetworkManager
127.0.0.1 localhost.localdomain localhost
::1 wagga01.example1111.com wagga01 localhost6.localdomain6 localhost6
[root@wagga01 ~]#
[root@wagga01 ~]#
[root@wagga01 ~]# cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=wagga01.example1111.com
[root@wagga01 ~]#
[root@wagga01 ~]#
[root@wagga01 ~]# hostname
wagga01.example1111.com
[root@wagga01 ~]#
[root@wagga01 ~]#
[root@wagga01 ~]# cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=wagga01.example.com
[root@wagga01 ~]#
[root@wagga01 ~]#
[root@wagga01 ~]# hostname
wagga01.example1111.com
[root@wagga01 ~]#
[root@wagga01 ~]# shutdown -r now
[root@wagga01 ~]# hostname
wagga01.example.com
[root@wagga01 ~]#
[root@wagga01 ~]#
[root@wagga01 ~]# cat /etc/hosts
10.0.2.15 wagga01.example.com wagga01 # Added by NetworkManager
127.0.0.1 localhost.localdomain localhost
::1 wagga01.example.com wagga01 localhost6.localdomain6 localhost6
[root@wagga01 ~]#
[root@wagga01 ~]#
[root@wagga01 ~]# cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=wagga01.example.com
[root@wagga01 ~]#
In case you are on centos or redhat then there is an easy way that is
# hostnamectl set-hostname wagga01.example.com
Then reboot:
# shutdown -r now
No comments:
Post a Comment