修改主机名称

查看当前主机别名

[root@192 ~]# hostname
192.168.222.131

修改主机别名为centos7

[root@192 ~]# hostnamectl set-hostname centos7  # 使用这个命令会立即生效且重启也生效

编辑下hosts文件, 给127.0.0.1添加hostname

[root@192 ~]$ vim /etc/hosts

检查

[root@192 ~]$ cat /etc/hosts

127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 centos7
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6

重启服务器

[root@192 ~]# reboot

 

posted @ 2022-10-22 16:03  O波V步  阅读(43)  评论(0编辑  收藏  举报