Unbuntu 18 修改主机名

sudo nano /etc/hostname修改需要的主机名。

  1. #vim /etc/cloud/cloud.cfg
    将preserve_hostname: false修改为true

  2. # vim /etc/hostname
    Your new Hostname

  3. # sudo reboot

修改示例

root@k8s-master:~# cat /etc/hostname
k8s-master
root@k8s-master:~# cat /etc/cloud/cloud.cfg
# The top level settings are used as module
# and system configuration.

# A set of users which may be applied and/or used by various modules
# when a 'default' entry is found it will reference the 'default_user'
# from the distro configuration specified below
users:
   - default

# If this is set, 'root' will not be able to ssh in and they
# will get a message to login instead as the default $user
disable_root: true

# This will cause the set+update hostname module to not operate (if true)
preserve_hostname: true

你可能感兴趣的:(Unbuntu 18 修改主机名)