Change hostname without reboot on CentOS 7 / RHEL 7

0

CentOS 7

Of course this post is a duplicate of Change HostName in CentOS 7 / RHEL 7. hostnamectl is used to change the host name on the fly (when the host name is set using this command; we do not require to reboot the machine). hostnamectl will directly update the kernel about change in hostname.

Check the current host name.

[root@server ~]# hostnamectl status
Static hostname: server.itzgeek.com
Icon name: computer-vm
Chassis: vm
Machine ID: 565ea8b749544aca9d5563308f9e4bc2
Boot ID: 5c979d9b5f754df8b75a4e3aeabf2bad
Virtualization: vmware
Operating System: CentOS Linux 7 (Core)
CPE OS Name: cpe:/o:centos:centos:7
Kernel: Linux 3.10.0-123.el7.x86_64
Architecture: x86_64

Set the hostname.

[root@server ~]# hostnamectl set-hostname client.itzgeek.com

Re-launch the session (Putty or console) and check the hostname.

[root@client ~]# hostnamectl status
Static hostname: client.itzgeek.com
Icon name: computer-vm
Chassis: vm
Machine ID: 565ea8b749544aca9d5563308f9e4bc2
Boot ID: 5c979d9b5f754df8b75a4e3aeabf2bad
Virtualization: vmware
Operating System: CentOS Linux 7 (Core)
CPE OS Name: cpe:/o:centos:centos:7
Kernel: Linux 3.10.0-123.el7.x86_64
Architecture: x86_64

That’s All!.

You might also like