更改 /etc/sysconfig/network 文件下 HOSTNAME 属性。
[root@iZ2zeiba2yyjy571kc00ghZ ~]# vim /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=wch #更改为自己的主机名
NETWORKING_IPV6=no
PEERNTP=no
GATEWAY=172.17.191.253
more 命令查看文件内容
[root@iZ2zeiba2yyjy571kc00ghZ ~]# more /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=wch
NETWORKING_IPV6=no
PEERNTP=no
GATEWAY=172.17.191.253
更改 /etc/hosts 文件,格式为:
ip hostname localhost
[root@iZ2zeiba2yyjy571kc00ghZ ~]# vim /etc/hosts
127.0.0.1 wch localhost
[root@iZ2zeiba2yyjy571kc00ghZ ~]# ping wch
PING wch (127.0.0.1) 56(84) bytes of data.
64 bytes from wch (127.0.0.1): icmp_seq=1 ttl=64 time=0.012 ms
64 bytes from wch (127.0.0.1): icmp_seq=2 ttl=64 time=0.025 ms
64 bytes from wch (127.0.0.1): icmp_seq=3 ttl=64 time=0.024 ms
^C
--- wch ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2127ms
rtt min/avg/max/mdev = 0.012/0.020/0.025/0.007 ms
重启、登陆
[root@iZ2zeiba2yyjy571kc00ghZ ~]# reboot
...
[root@wch ~]# hostname
wch
完成!
网友评论