Linux Ubuntu16.04和18.04修改主机名的方法,Linux Ubuntu系统怎么修改主机名?

2020-02-24
0评论
/
1095阅读
爱搜啊

Linux Ubuntu16.04和18.04修改主机名的方法

常用命令

查看当前主机名

hostname
# 或者
uname -a

Ubuntu 16.04 修改主机名

1.修改/etc/hostname文件

vi /etc/hostname

修改成你需要的主机名后保存退出;

2.修改/etc/hosts配置文件

vi /etc/hosts
# 在第二行添加
127.0.1.1 sunpma(sunpma为你刚才设置的主机名)

3.重启系统使其生效

sudo reboot

Ubuntu 18.04 修改主机名

1.修改/etc/cloud/cloud.cfg文件

vi /etc/cloud/cloud.cfg

找到preserve_hostname: false将其修改为preserve_hostname: true

2.修改/etc/hostname文件

vi /etc/hostname

修改成你需要的主机名后保存退出;

3.修改/etc/hosts配置文件

# 在第二行添加
127.0.1.1 sunpma(sunpma为你刚才设置的主机名)

4.重启系统使其生效

sudo reboot

本站附件分享,如果附件失效,可以去找找看

诚通网盘附件百度网盘附件


标签: linux Ubuntu
于2020-02-24发布