在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
centos7 上在主机名变更新增了一个hostnamectl 指令 ,该指令的无论在输出和更改上都较之前更加的便利。先看下hostname的help帮助信息: 复制代码 代码如下:[root@361way ~]# hostnamectl --help hostnamectl [OPTIONS...] COMMAND ... Query or change system hostname. -h --help Show this help --version Show package version --transient Only set transient hostname --static Only set static hostname --pretty Only set pretty hostname -P --privileged Acquire privileges before execution --no-ask-password Do not prompt for password -H --host=[USER@]HOST Operate on remote host 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 查看hostname信息 复制代码 代码如下:[root@361way ~]# hostnamectl Static hostname: 361way Icon name: computer-desktop Chassis: desktop Machine ID: 6917731f5fe447d0bca296ed2802e250 Boot ID: e0d20bc2a3a4474c960394967d33ab53 Operating System: CentOS Linux 7 (Core) CPE OS Name: cpe:/o:centos:centos:7 Kernel: Linux 3.10.0-123.6.3.el7.x86_64 Architecture: x86_64 设置主机名 从上面的help 帮助里可以看到,在设置主机名时,这里涉及到四种主机名,在hostnamectl 的man手册里给予了说明和解释,如下: This tool distinguishes three different hostnames: the high-level "pretty" hostname which might include all kinds of special characters (e.g. "Lennart's 一般情况下都是使用set-hostname进行更改: 复制代码 代码如下:[root@361way ~]# hostnamectl set-hostname blog 更改主机名一般会涉及到/etc/hostname 、/etc/machine-info 两个文件,同时对于不同的名字修改在man手册上也给了说明: The static hostname is stored in /etc/hostname, see hostname(5) for more information. The pretty hostname, chassis type, and icon name are stored in /etc/machine-info, see machine-id(5). |
请发表评论