常用命令
查看当前主机名
hostname
# 或者
uname -aUbuntu 16.04 修改主机名
第一步
修改/etc/hostname文件
vi /etc/hostname修改成你需要的主机名后保存退出;
第二步
修改/etc/hosts配置文件
vi /etc/hosts
# 在第二行添加
127.0.1.1 sunpma(sunpma为你刚才设置的主机名)第三步
重启系统使其生效
sudo rebootUbuntu 18.04 修改主机名
第一步
修改/etc/cloud/cloud.cfg文件
vi /etc/cloud/cloud.cfg找到preserve_hostname: false将其修改为preserve_hostname: true
第二步
修改/etc/hostname文件
vi /etc/hostname修改成你需要的主机名后保存退出;
第三步
修改/etc/hosts配置文件
# 在第二行添加
127.0.1.1 sunpma(sunpma为你刚才设置的主机名)第四步
重启系统使其生效
sudo reboot版权声明:本文为原创文章,版权归 suntl.com 所有,转载请注明出处!
本文链接:https://suntl.com/785.html
友情提示:如果博客出现404或链接失效,请留言或者联系博主修复!
