Change Hostname in CentOS 7
After upgrading the VPS system to CentOS 7, I tried to modify/etc/sysconfig/network to modify the hostname, but it was useless. the method for modifying the Hostname of CentOS 7 is different from that of the previous version. We hope this article will help you modify the Hostname on CentOS 7/RHEL 7.
Use hostnamectl to modify Hostname:
Check the current Hostname
[Root @ bkjia ~] # Hostnamectl status
Static hostname: bkjia. guest
Icon name: computer-vm
Chassis: vm
Machine ID: 19a12d5f5dda-794a19caf165a9b3bca
Boot ID: 21c75ffe0718431d800fd8159be13d99
Virtualization: kvm
Operating System: CentOS Linux 7 (Core)
Cpe OS Name: cpe:/o: centos: 7
Kernel: Linux 3.10.0-123.20.1.el7.x86 _ 64
Architecture: x86_64
Set a new Hostname
[Root @ bkjia ~] # Hostnamectl set-hostname mysql.jzbk.org
Check the current Hostname
[Root @ bkjia ~] # Hostnamectl status
Static hostname: mysql.jzbk.org
Icon name: computer-vm
Chassis: vm
Machine ID: 19a12d5f5dda-794a19caf165a9b3bca
Boot ID: 21c75ffe0718431d800fd8159be13d99
Virtualization: kvm
Operating System: CentOS Linux 7 (Core)
Cpe OS Name: cpe:/o: centos: 7
Kernel: Linux 3.10.0-123.20.1.el7.x86 _ 64
Architecture: x86_64