CentOS 7更改Hostname
在把VPS上的系统升级到CentOS 7之后,我尝试修改/etc/sysconfig/network来修改hostname, 但是没有用. 修改CentOS 7的Hostname的方法和以前版本不同,希望本文能帮你来修改Hostname在CentOS 7 / RHEL 7上。
使用hostnamectl来修改Hostname:
检查目前的Hostname
[root@linuxidc ~]# hostnamectl status
Static hostname: linuxidc.guest
Icon name: computer-vm
Chassis: vm
Machine ID: 19a12d5f5d824794a19caf165a9b3bca
Boot ID: 21c75ffe0718431d800fd8159be13d99
Virtualization: kvm
Operating System: CentOS Linux 7 (Core)
CPE OS Name: cpe:/o:centos:centos:7
Kernel: Linux 3.10.0-123.20.1.el7.x86_64
Architecture: x86_64
设置新的Hostname
[root@linuxidc ~]# hostnamectl set-hostname mysql.jzbk.org
检查当前Hostname
[root@linuxidc ~]# hostnamectl status
Static hostname: mysql.jzbk.org
Icon name: computer-vm
Chassis: vm
Machine ID: 19a12d5f5d824794a19caf165a9b3bca
Boot ID: 21c75ffe0718431d800fd8159be13d99
Virtualization: kvm
Operating System: CentOS Linux 7 (Core)
CPE OS Name: cpe:/o:centos:centos:7
Kernel: Linux 3.10.0-123.20.1.el7.x86_64
Architecture: x86_64