修改 Centos7 主机名

Centos 7 中自带了 hostnamectl 工具,使用该命令行工具可以查看或修改主机名相关配置。

查看

hostnamectl

可以看到如下相似内容:

   Static hostname: localhost.localdomain
         Icon name: computer-vm
           Chassis: vm
        Machine ID: ...
           Boot ID: ...
    Virtualization: vmware
  Operating System: CentOS Linux 7 (Core)
       CPE OS Name: cpe:/o:centos:centos:7
            Kernel: Linux 3.10.0-693.11.1.el7.x86_64
      Architecture: x86-64

修改

hostnamectl set-hostname StarUDream

重启之后即可看到主机名已修改。

猜你喜欢

转载自www.cnblogs.com/StarUDream/p/9045474.html