Ubuntu 18.04修改hostname

2020-09-07  本文已影响0人  TEYmL

获取sudo权限

sudo su 

查看主机名

hostnamectl
root@ubuntu:/home/openstcinder# hostnamectl
   Static hostname: ubuntu
         Icon name: computer-vm
           Chassis: vm
        Machine ID: 994e6615bf81477ebc1c0c9eec126d40
           Boot ID: b7142ceb401a4c318212dc2a2e0e56a7
    Virtualization: vmware
  Operating System: Ubuntu 18.04.4 LTS
            Kernel: Linux 4.15.0-76-generic
      Architecture: x86-64

当前hostname为ubuntu

更改主机名

使用hostnamectl来更改

hostnamectl set-hostname openstcinder
root@ubuntu:/home/openstcinder# hostnamectl set-hostname openstcinder
root@ubuntu:/home/openstcinder# 

成功无输出

使用编辑器更改/etc/hosts文件的hostname

vi /etc/hosts
i
#修改hostname
修改hostname

重启生效

reboot now

查看新hostname

openstcinder@openstcinder:~$ hostnamectl
   Static hostname: openstcinder
         Icon name: computer-vm
           Chassis: vm
        Machine ID: 994e6615bf81477ebc1c0c9eec126d40
           Boot ID: 651ca89ecdad4bd2a92d9505b4b7f81d
    Virtualization: vmware
  Operating System: Ubuntu 18.04.4 LTS
            Kernel: Linux 4.15.0-76-generic
      Architecture: x86-64
上一篇 下一篇

猜你喜欢

热点阅读