ubuntu server修改hostname(terminal)
查看hostname命令
output
- Static hostname: pyserver
- Icon name: computer-vm
- Chassis: vm
- Machine ID: 0d172244wer234342552229a5aabf0ba15
- Boot ID: bdf1a662353f24ff2409ba717256fd0ec15
- Virtualization: microsoft
- Operating System: Ubuntu 20.04.1 LTS
- Kernel: Linux 5.4.0-42-generic
- Architecture: x86-64
复制代码
改hostname
- sudo hostnamectl set-hostname new_name
复制代码
除了修改这个外还要改
output
- 127.0.0.1 localhost
- 127.0.0.1 DR <------change this
- # The following lines are desirable for IPv6 capable hosts
- ::1 localhost ip6-localhost ip6-loopback
- ff02::1 ip6-allnodes
- ff02::2 ip6-allrouters
复制代码
接下来
- sudo vim /etc/cloud/cloud.cfg
复制代码preserve_hostname: false改成true 重启生效
|