rhel主机名修改
- 在机器上马上生效
hostname rhel(主机名)
- 在rhel6中,机器重启后生效
vim/etc/sysconfig/network
hostname=rhel6(主机名) //参考配置文件范例灵活操作
- 在rhel7中,机器重启后生效果
vim/etc/hostname
rhel7 //参考配置文件范例灵活操作
hostname命令得到的是和上述文件一样的结果。
- /etc/hostname和/etc/hosts区别:
/etc/hostname中存放的是主机名,hostname文件的一个例子:
rhel
/etc/hosts存放的是域名与ip的对应关系,域名与主机名没有任何关系,你可以为任何一个IP指定任意一个名字,hostname文件的一个例子:
127.0.0.1 localhost
127.0.1.1 rhel
并为了保证方便,/etc/hostname 与 /etc/hosts 文件中主机名应该一致