修改主机名命令hostnamectl set-hostname <新名称>
命令帮助如下:
[root@localhost ~]# hostnamectl --help hostnamectl [OPTIONS...] COMMAND ... Query or change system hostname. -h --help Show this help --version Show package version --no-ask-password Do not prompt for password -H --host=[USER@]HOST Operate on remote host -M --machine=CONTAINER Operate on local container --transient Only set transient hostname --static Only set static hostname --pretty Only set pretty hostname Commands: status Show current hostname settings set-hostname NAME Set system hostname set-icon-name NAME Set icon name for host set-chassis NAME Set chassis type for host set-deployment NAME Set deployment environment for host set-location NAME Set location for host
命令查询和修改
[root@localhost ~]# hostnamectl
Static hostname: localhost.localdomain
Icon name: computer-vm
Chassis: vm
Machine ID: 867aaa1c353c4aad8510c0ee973bc083
Boot ID: 6f9f8d5dd4f7426daff92ee2e0b736cf
Virtualization: kvm
Operating System: CentOS Linux 7 (Core)
CPE OS Name: cpe:/o:centos:centos:7
Kernel: Linux 3.10.0-693.11.1.el7.x86_64
Architecture: x86-64
[root@localhost ~]# hostnamectl set-hostname openstack
[root@localhost ~]# hostnamectl
Static hostname: openstack
Icon name: computer-vm
Chassis: vm
Machine ID: 867aaa1c353c4aad8510c0ee973bc083
Boot ID: 6f9f8d5dd4f7426daff92ee2e0b736cf
Virtualization: kvm
Operating System: CentOS Linux 7 (Core)
CPE OS Name: cpe:/o:centos:centos:7
Kernel: Linux 3.10.0-693.11.1.el7.x86_64
Architecture: x86-64