hostnamectl 修改 CentOS7 主机名
Posted 江湖小小白
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了hostnamectl 修改 CentOS7 主机名相关的知识,希望对你有一定的参考价值。
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 for password -H --host=[[email protected]]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
查看主机名
cat /etc/hostname hostname
修改主机名 (非临时)
vim /etc/hostname hostnamectl set-hostname xxxx
以上是关于hostnamectl 修改 CentOS7 主机名的主要内容,如果未能解决你的问题,请参考以下文章