hostnamectl 修改 CentOS7 主機名

hostnamectl 控制主機名vim

# 顯示狀態 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 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

 

查看主機名centos

cat /etc/hostname

hostname

 

修改主機名 (非臨時)this

vim /etc/hostname hostnamectl set-hostname xxxx
相關文章
相關標籤/搜索