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
实践
显示主机名和相关信息
设置主机名
参考资料
【1】man hostnamectl
安装了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
相关文章推荐
- 每天学习一个linux命令(8):cp 命令
- 每天学习一个linux命令(2):cd命令
- 每天学习一个linux命令(15):tail 命令
- 每天学习一个linux命令(13):less 命令
- Linux学习17_每天一个linux命令(5):rm 命令
- 每天学习一个linux命令(9):touch 命令
- 每天学习一个linux命令(6):rmdir 命令
- 推荐一个学习linux 命令比较好多方式
- linux学习一天一个命令(3)[pwd命令]
- Linux学习20_每天一个linux命令(9):touch 命令
- linux学习一天一个命令(4)[mkdir命令]
- 字串处理 expr在linux中是一个功能非常强大的命令。通过学习做一个小小的总结。
- Linux学习22_每天一个linux命令(27):chmod命令
- Linux学习19_每天一个linux命令(10):cat 命令
- 每天学习一个linux命令(12):more命令
- Linux学习一天一个命令(1)[ls命令]
- 每天学习一个linux命令(5):rm 命令
- linux:每天学习一个命令——清屏
- 每天学习一个linux命令(7):mv命令
- 每天学习一个linux命令(14):head 命令