Changing the hostname on Centos 7
-------------------------------------------
1) To check the current hostname of the Server/VM
[root@dhana-testrhel7 ~]# hostname
dhana-testrhel7
[root@dhana-testrhel7 ~]# cat /etc/sysconfig/network
# Created by anaconda
HOSTNAME=cs-centos7vm-01.test.com
GATEWAY=192.168.10.1
[root@dhana-testrhel7 ~]#
[root@dhana-testrhel7 ~]# hostnamectl status
Static hostname: dhana-testrhel7
Icon name: computer-vm
Chassis: vm
Machine ID: f786930c19gd428fa8d40d328573bd67
Boot ID: 0b0dfb1f19j54b44b90c2d94bb91c785
Virtualization: vmware
Operating System: Red Hat Enterprise Linux Server 7.3 (Maipo)
CPE OS Name: cpe:/o:redhat:enterprise_linux:7.3:GA:server
Kernel: Linux 3.10.0-514.el7.x86_64
Architecture: x86-64
[root@dhana-testrhel7 ~]#
2) To change the hostname to cs-centos7vm-01
[root@dhana-testrhel7 ~]# hostnamectl set-hostname cs-centos7vm-01
[root@dhana-testrhel7 ~]# hostname
cs-centos7vm-01.test.com
[root@dhana-testrhel7 ~]# hostnamectl status
Static hostname: cs-centos7vm-01.test.com
Icon name: computer-vm
Chassis: vm
Machine ID: f786930c19gd428fa8d40d328573bd67
Boot ID: 0b0dfb1f19j54b44b90c2d94bb91c785
Virtualization: vmware
Operating System: Red Hat Enterprise Linux Server 7.3 (Maipo)
CPE OS Name: cpe:/o:redhat:enterprise_linux:7.3:GA:server
Kernel: Linux 3.10.0-514.el7.x86_64
Architecture: x86-64
[root@dhana-testrhel7 ~]#
3) Reboot the server to apply permanently.
[root@dhana-testrhel7 ~]# reboot
[root@cs-centos7vm-01 ~]# hostname
cs-centos7vm-01.test.com
-------------------------------------------
1) To check the current hostname of the Server/VM
[root@dhana-testrhel7 ~]# hostname
dhana-testrhel7
[root@dhana-testrhel7 ~]# cat /etc/sysconfig/network
# Created by anaconda
HOSTNAME=cs-centos7vm-01.test.com
GATEWAY=192.168.10.1
[root@dhana-testrhel7 ~]#
[root@dhana-testrhel7 ~]# hostnamectl status
Static hostname: dhana-testrhel7
Icon name: computer-vm
Chassis: vm
Machine ID: f786930c19gd428fa8d40d328573bd67
Boot ID: 0b0dfb1f19j54b44b90c2d94bb91c785
Virtualization: vmware
Operating System: Red Hat Enterprise Linux Server 7.3 (Maipo)
CPE OS Name: cpe:/o:redhat:enterprise_linux:7.3:GA:server
Kernel: Linux 3.10.0-514.el7.x86_64
Architecture: x86-64
[root@dhana-testrhel7 ~]#
2) To change the hostname to cs-centos7vm-01
[root@dhana-testrhel7 ~]# hostnamectl set-hostname cs-centos7vm-01
[root@dhana-testrhel7 ~]# hostname
cs-centos7vm-01.test.com
[root@dhana-testrhel7 ~]# hostnamectl status
Static hostname: cs-centos7vm-01.test.com
Icon name: computer-vm
Chassis: vm
Machine ID: f786930c19gd428fa8d40d328573bd67
Boot ID: 0b0dfb1f19j54b44b90c2d94bb91c785
Virtualization: vmware
Operating System: Red Hat Enterprise Linux Server 7.3 (Maipo)
CPE OS Name: cpe:/o:redhat:enterprise_linux:7.3:GA:server
Kernel: Linux 3.10.0-514.el7.x86_64
Architecture: x86-64
[root@dhana-testrhel7 ~]#
3) Reboot the server to apply permanently.
[root@dhana-testrhel7 ~]# reboot
[root@cs-centos7vm-01 ~]# hostname
cs-centos7vm-01.test.com
No comments:
Post a Comment