您的位置:首页 > 运维架构 > Linux

CentOS 7.0 修改hostname

2016-04-10 11:35 591 查看
linux中修改hostname,可以临时修改hostname也可以永久修改,临时修改无需重新启动,立即生效。

临时修改hostname

#hostname //查看当前hostname
#hostname newname  //临时修改hostname


永久修改hostname

要永久修改hostname需要修改文件,
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, ypdomain‐name and nisdomainname use setdomainname(2). Note, that this is effec‐

tive only until the next reboot. Edit /etc/hostname for permanent

change.

如果我们要修改永久修改hostname,可以通过修改
/etc/hostname
文件来实现,使用vim将该文件中的hostname 替换为要修改的值即可。

注:

如果要永久修改RedHat的hostname,就修改/etc/sysconfig/network文件,将里面的HOSTNAME这一行修改成HOSTNAME=NEWNAME,其中NEWNAME就是你要设置的hostname。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: