Example:将bogon 改为 adelababy

Oracle Linux 6.5 

[root@bogon ~]# hostname

bogon

[root@bogon ~]# hostname adelababy

[root@bogon ~]# hostname

adelababy

 

[root@bogon ~]# vim /etc/sysconfig/network

NETWORKING=yes

HOSTNAME=adelababy

[root@bogon ~]# reboot

 

[root@adelababy Desktop]# hostname

adelababy


[root@adelababy Desktop]# vim /etc/hosts
127.0.0.1   localhost adelababy


[root@adelababy Desktop]# ping adelababy
PING localhost (127.0.0.1) 56(84) bytes of data.
64 bytes from localhost (127.0.0.1): icmp_seq=1 ttl=64 time=0.025 ms
64 bytes from localhost (127.0.0.1): icmp_seq=2 ttl=64 time=0.069 ms



RHEL 7.0

#sethostname adelababy

#hostname