歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux綜合 >> 學習Linux >> CentOS 7.0 修改hostname

CentOS 7.0 修改hostname

日期:2017/3/6 9:48:55   编辑:學習Linux

CentOS 7.0 修改hostname


CentOS 7.0 修改hostname


centos中修改hostname,可以臨時修改hostname也可以永久修改,臨時修改無需重新啟動,立即生效。

臨時修改hostname

#hostname //查看當前hostname #hostname newname  //臨時修改hostname

永久修改hostname

要永久修改hostname需要修改文件,man hostname查看使用手冊是,有這樣一段,

SET NAME When called with one argument or with the- -fileoption, the commands set the host name or the NIS/YP domain name.hostnameuses the sethostname(2) function, while all of the threedomainname,ypdomain‐nameandnisdomainnameusesetdomainname(2). Note, that this is effec‐ tive only until the next reboot. Edit/etc/hostnamefor permanent change.

如果我們要修改永久修改hostname,可以通過修改/etc/hostname文件來實現,使用vim將該文件中的hostname 替換為要修改的值即可。


注: 如果要永久修改RedHat的hostname,就修改/etc/sysconfig/network文件,將裡面的HOSTNAME這一行修改成HOSTNAME=NEWNAME,其中NEWNAME就是你要設置的hostname。

http://xxxxxx/Linuxjc/1134170.html TechArticle

Copyright © Linux教程網 All Rights Reserved