红帽7之hostnamectl 实用小命令用法

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了红帽7之hostnamectl 实用小命令用法相关的知识,希望对你有一定的参考价值。


rhel7 很多命令和rhel6 都不一样了,大家需要学习喽。

先从hostnamectl 开始哈


[[email protected] ~]# 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
[[email protected] ~]# 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
[[email protected] ~]# 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=[[email protected]]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
[[email protected] ~]# cat /etc/hostname   --配置文件
roidb02
[[email protected] ~]# hostnamectl set-hostname roidb01
[[email protected] ~]# cat /etc/hostname    --配置文件直接生效了有没有
roidb01
[[email protected] ~]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
[[email protected] ~]#
[[email protected] ~]#
[[email protected] ~]# init 6  --重启验证


Last login: Sun Oct 15 07:23:33 2017 from gateway
不拉不拉省略.........

..................

[[email protected] ~]#
[[email protected] ~]#
[[email protected] ~]#
[[email protected] ~]#
[[email protected] ~]#
[[email protected] ~]# 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
[[email protected] ~]# cat /etc/hostname
roidb01

[[email protected] ~]#


小视频网盘地址:链接:http://pan.baidu.com/s/1i5pa4yL 密码:em8x

本文出自 “roidba” 博客,请务必保留此出处http://roidba.blog.51cto.com/12318731/1972450

以上是关于红帽7之hostnamectl 实用小命令用法的主要内容,如果未能解决你的问题,请参考以下文章

实用小命令汇总(个人使用)

linux实用小命令--查看文本内容

小命令taccatrev的用法

Linux简单实用小命令010面试常问:Linux怎么查看cpu内存和磁盘的使用率?

Git 实用小命令收集

Linux小命令date详解