[root@brj ~]# cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=brj
[root@brj ~]# hostname
brj
[root@brj ~]# hostname oldboy36
[root@brj ~]# sed 's#HOSTNAME=.*#HOSTNAME=oldboy36#' /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=oldboy36
[root@brj ~]# sed 's#HOSTNAME=.*#HOSTNAME=oldboy36#' /etc/sysconfig/network -i
[root@brj ~]# cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=oldboy36
详细说明如何设置linux主机名(临时和永久)