一直苦于无法永久修改主机名,man了一下hostname,里面居然已经有了详细的说明:
SET NAME When called with one argument or with the --file option, the commands set the host name or the NIS/YP domain name. hostname uses the sethostname(2) function, while all of the three domainname, ypdomainname and nisdomainname use setdomainname(2). Note, that this is effec‐ tive only until the next reboot. Edit /etc/hostname for permanent change.
编辑/etc/hostname即可永久修改,于是修改为
#localhost.localhostdomain myhostname
重启后依旧不行。
按网上的说法修改/etc/sysconfig/network也是不行(http://soft.chinabyte.com/os/281/11563281.shtml)
后来去掉了myhostname上面那一条注释
#local.localhostdomain
重启后主机名居然变成了myhostname
本文出自 “DayDayYiDay的技术路” 博客,请务必保留此出处http://daydayyiday.blog.51cto.com/7714670/1858388
原文地址:http://daydayyiday.blog.51cto.com/7714670/1858388