centos设置hostname

hostnamectl set-hostname newhostname  #reboot后也是生效的

vim /etc/hosts                                                   #编辑下hosts文件, 给127.0.0.1添加newhostname

例:

127.0.0.1    localhost localhost.localdomain localhost4 localhost4.localdomain4 newhostname

::1    localhost localhost.localdomain localhost6 localhost6.localdomain6

你可能感兴趣的:(centos设置hostname)