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=[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
查看主机名
cat /etc/hostname hostname
修改主机名 (非临时)
vim /etc/hostname hostnamectl set-hostname xxxx
原文地址:https://www.cnblogs.com/jhxxb/p/10569057.html
时间: 2024-11-02 20:23:17