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

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容