操作系统:RHECL 7/CentOS 7

任务:通过命令静态修改主机名,当然也可以通过修改hostname文件。

[root@localhost yum.repos.d]# hostnamectl

   Static hostname: localhost.localdomain

         Icon name: computer-vm

           Chassis: vm

        Machine ID: fbb6652b326c4bdca62b483b472a88d0

           Boot ID: 479380da3a3a40ce8effc0704e1ad133

    Virtualization: vmware

  Operating System: CentOS Linux 7 (Core)

       CPE OS Name: cpe:/o:centos:centos:7

            Kernel: Linux 3.10.0-862.14.4.el7.x86_64

      Architecture: x86-64

[root@localhost yum.repos.d]# hostnamectl --static set-hostname CentOS7

[root@localhost yum.repos.d]# hostname

CentOS7