CentOS7 修改Hostname
最近想修改Centos7的hostname, 可是如果直接修改hostname文件不生效,今天查了查原來centos有幾種hostname.
hostnamectl 控制整個系統的hostname,推薦使用
nmtul 使用text ui 控制
nmtcli 可以用但是不推薦使用
[root@willweb ~]# hostnamectl status
Static hostname: willweb
Icon name: computer-vm
Chassis: vm
Machine ID: f9d400c5e1e8c3a8209e990d887d4ac1
Boot ID: dd7be45d652849dcb82493c286c69dbf
Virtualization: kvm
Operating System: CentOS Linux 7 (Core)
CPE OS Name: cpe:/o:centos:centos:7
Kernel: Linux 3.10.0-327.el7.x86_64
Architecture: x86-64
[root@willweb ~]# hostname
willweb
[root@willweb ~]# hostnamectl
Static hostname: willweb
Icon name: computer-vm
Chassis: vm
Machine ID: f9d400c5e1e8c3a8209e990d887d4ac1
Boot ID: dd7be45d652849dcb82493c286c69dbf
Virtualization: kvm
Operating System: CentOS Linux 7 (Core)
CPE OS Name: cpe:/o:centos:centos:7
Kernel: Linux 3.10.0-327.el7.x86_64
Architecture: x86-64
[root@willweb ~]# hostnamectl status
Static hostname: willweb
Icon name: computer-vm
Chassis: vm
Machine ID: f9d400c5e1e8c3a8209e990d887d4ac1
Boot ID: dd7be45d652849dcb82493c286c69dbf
Virtualization: kvm
Operating System: CentOS Linux 7 (Core)
CPE OS Name: cpe:/o:centos:centos:7
Kernel: Linux 3.10.0-327.el7.x86_64
Architecture: x86-64
使用命令如下nmtul 使用text ui 控制
nmtcli 可以用但是不推薦使用
[root@willweb ~]# hostnamectl status
Static hostname: willweb
Icon name: computer-vm
Chassis: vm
Machine ID: f9d400c5e1e8c3a8209e990d887d4ac1
Boot ID: dd7be45d652849dcb82493c286c69dbf
Virtualization: kvm
Operating System: CentOS Linux 7 (Core)
CPE OS Name: cpe:/o:centos:centos:7
Kernel: Linux 3.10.0-327.el7.x86_64
Architecture: x86-64
[root@willweb ~]# hostname
willweb
[root@willweb ~]# hostnamectl
Static hostname: willweb
Icon name: computer-vm
Chassis: vm
Machine ID: f9d400c5e1e8c3a8209e990d887d4ac1
Boot ID: dd7be45d652849dcb82493c286c69dbf
Virtualization: kvm
Operating System: CentOS Linux 7 (Core)
CPE OS Name: cpe:/o:centos:centos:7
Kernel: Linux 3.10.0-327.el7.x86_64
Architecture: x86-64
[root@willweb ~]# hostnamectl status
Static hostname: willweb
Icon name: computer-vm
Chassis: vm
Machine ID: f9d400c5e1e8c3a8209e990d887d4ac1
Boot ID: dd7be45d652849dcb82493c286c69dbf
Virtualization: kvm
Operating System: CentOS Linux 7 (Core)
CPE OS Name: cpe:/o:centos:centos:7
Kernel: Linux 3.10.0-327.el7.x86_64
Architecture: x86-64
# hostnamectl set-hostname Your-New-Host-Name-Here
# hostnamectl set-hostname "Your New Host Name Here" --pretty
# hostnamectl set-hostname Your-New-Host-Name-Here --static
# hostnamectl set-hostname Your-New-Host-Name-Here --transient
遠程設置hostname# hostnamectl set-hostname "Your New Host Name Here" --pretty
# hostnamectl set-hostname Your-New-Host-Name-Here --static
# hostnamectl set-hostname Your-New-Host-Name-Here --transient
ssh root@server-ip-here hostnamectl set-hostname server1
hostnamectl set-hostname server1 -H root@192.168.1.42
hostnamectl set-hostname server1 -H root@192.168.1.42
posted on 2016-11-10 09:52 草原上的駱駝 閱讀(2810) 評論(0) 編輯 收藏 所屬分類: Linux