存hostname的几个文件
- cat /etc/sysconfig/network 是开机检测的Hostname文件
[[email protected] craft]# cat /etc/sysconfig/network
HOSTNAME=AAEP7151
NETWORKING=yes
2.
[[email protected] craft]# hostname hostname指令用于查询本机hostname
AAEP7151
[[email protected] craft]# cat /etc/hosts
127.0.0.1 localhost.localdomain localhost localhost4
::1 localhost6.localdomain6 localhost6
135.122.53.151 AAEP7151 AAEP7151.sdr.avaya.com EPM MPP1
10.133.13.86 DALIANAACC64
[[email protected] craft]# cat /proc/sys/kernel/hostname
AAEP7151
现在,用hostname指令更改hostname
[[email protected] craft]# hostname AAAA
[[email protected] craft]# hostname
AAAA 更改成功
[[email protected] craft]# cat /proc/sys/kernel/hostname
AAAA 更改额内容保存在/proc/sys/kernel/hostname里面,也随着更改
[[email protected] craft]# cat /etc/sysconfig/network 文件里的hostname不变
HOSTNAME=AAEP7151
NETWORKING=yes
[[email protected] craft]# cat /etc/hosts
127.0.0.1 localhost.localdomain localhost localhost4
::1 localhost6.localdomain6 localhost6
135.122.53.151 AAEP7151 AAEP7151.sdr.avaya.com EPM MPP1
现在reboot 服务器,发现用hostname命令更改的只是 暂时保存在kernel里,随着重启,会重新去/etc/sysconfig/network里读Hostname。
另外,直接更改文件里的Hostname需要非常谨慎,使用hostname的地方非常多,后果自负。