hostnamectl 修改 CentOS7 主機名
阿新 • • 發佈:2019-03-21
mach 3.1 his contain option name arc ont -h
hostnamectl 控制主機名
# 顯示狀態 hostnamectl Static hostname: centos Icon name: computer-vm Chassis: vm Machine ID: a0cacaa7df9a4b77808d5686a92f07bb Boot ID: bec1154b17bf4cdaa515ac528e4aab87 Virtualization: vmware Operating System: CentOS Linux 7 (Core) CPE OS Name: cpe:/o:centos:centos:7 Kernel: Linux 3.10.0-862.el7.x86_64 Architecture: x86-64 # 查看幫助 hostnamectl -h hostnamectl [OPTIONS...] COMMAND ... Query or change system hostname. -h --help Show this help --version Show package version --no-ask-password Do not prompt forpassword -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 currenthostname 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
查看主機名
cat /etc/hostname hostname
修改主機名 (非臨時)
vim /etc/hostname hostnamectl set-hostname xxxx
hostnamectl 修改 CentOS7 主機名