您的位置:首页 > 运维架构 > Linux

N天学习一个Linux命令之hostnamectl

2017-12-05 18:52 204 查看
前言

安装了CentOS7,发现按照以前修改文件/etc/sysconfig/network HOSTNAME字段主机名的方式不生效了,查资料发现可以使用hostnamectl命令

用途

Control the system hostname

用法

hostnamectl [options] {command}

常用选项

--static

the static hostname which is used to initialize the kernel hostname at boot

--transient

he transient hostname which is a default received from network configuration.

--pretty

the high-level "pretty" hostname which might include all kinds of special characters

实践

显示主机名和相关信息

[root@vm-node1 ~]# hostnamectl
Static hostname: vm-node1
Icon name: computer-vm
Chassis: vm
Machine ID: 97a20c207e324ad78ef902d44d77affd
Boot ID: 3663cc8de26b442c9bb84c4a07f4955a
Virtualization: oracle
Operating System: CentOS Linux 7 (Core)
CPE OS Name: cpe:/o:centos:centos:7
Kernel: Linux 3.10.0-693.el7.x86_64
Architecture: x86-64


  

设置主机名

[root@vm-node1 ~]# hostnamectl --static set-hostname vm-node1


  

参考资料

【1】man hostnamectl
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: