rhel7 很多命令和rhel6 都不一样了,大家需要学习喽。
先从hostnamectl 开始哈
[root@roidb02 ~]# hostnamectl
Static hostname: roidb02
Icon name: computer-vm
Chassis: vm
Machine ID: c3e6a26e2e00481f928f0c38b97cf5ab
Boot ID: f7d681692d96485ea81b3524c7743647
Virtualization: kvm
Operating System: Red Hat Enterprise Linux Server 7.3 (Maipo)
CPE OS Name: cpe:/o:redhat:enterprise_linux:7.3:GA:server
Kernel: Linux 3.10.0-514.el7.x86_64
Architecture: x86-64
[root@roidb02 ~]# hostnamectl status
Static hostname: roidb02
Icon name: computer-vm
Chassis: vm
Machine ID: c3e6a26e2e00481f928f0c38b97cf5ab
Boot ID: f7d681692d96485ea81b3524c7743647
Virtualization: kvm
Operating System: Red Hat Enterprise Linux Server 7.3 (Maipo)
CPE OS Name: cpe:/o:redhat:enterprise_linux:7.3:GA:server
Kernel: Linux 3.10.0-514.el7.x86_64
Architecture: x86-64
[root@roidb02 ~]# hostnamectl --help 帮助非常重要啊
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
[root@roidb02 ~]# cat /etc/hostname --配置文件
roidb02
[root@roidb02 ~]# hostnamectl set-hostname roidb01
[root@roidb02 ~]# cat /etc/hostname --配置文件直接生效了有没有
roidb01
[root@roidb02 ~]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
[root@roidb02 ~]#
[root@roidb02 ~]#
[root@roidb02 ~]# init 6 --重启验证
Last login: Sun Oct 15 07:23:33 2017 from gateway
不拉不拉省略.........
..................
[root@roidb01 ~]#
[root@roidb01 ~]#
[root@roidb01 ~]#
[root@roidb01 ~]#
[root@roidb01 ~]#
[root@roidb01 ~]# hostnamectl
Static hostname: roidb01
Icon name: computer-vm
Chassis: vm
Machine ID: c3e6a26e2e00481f928f0c38b97cf5ab
Boot ID: ec156edd01a84bdf8a4d8c91350a2ef2
Virtualization: kvm
Operating System: Red Hat Enterprise Linux Server 7.3 (Maipo)
CPE OS Name: cpe:/o:redhat:enterprise_linux:7.3:GA:server
Kernel: Linux 3.10.0-514.el7.x86_64
Architecture: x86-64
[root@roidb01 ~]# cat /etc/hostname
roidb01
[root@roidb01 ~]#
小视频网盘地址:链接:http://pan.baidu.com/s/1i5pa4yL 密码:em8x
本文出自 “roidba” 博客,请务必保留此出处http://roidba.blog.51cto.com/12318731/1972450
原文地址:http://roidba.blog.51cto.com/12318731/1972450