一直苦于无法永久修改主机名,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
时间: 2024-10-23 11:04:03