centos修改主机名
1、临时修改,重启失效
[root@centos17 ~]# hostname abc [root@centos17 ~]# hostname abc
2、永久修改,修改配置文件,重启生效
[root@centos17 ~]# cat /etc/hostname centos17
linux7.4使用系统自带的命令hostnamectl修改主机名,永久生效
[root@xxx ~]# cat /etc/hostname x160 [root@xxx ~]# hostnamectl set-hostname xxx [root@xxx ~]# cat /etc/hostname xxx [root@xxx ~]# hostname xxx
修改主机hosts文件,用域名替代ip
[root@centos17 ~]# cat /etc/hosts 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 [root@centos17 ~]#
为者常成,行者常至
Give me five~!