Redhat 5
Redhat6
1: hostname DB-Server --运行后立即生效(新会话生效),但是在系统重启后会丢失所做的修改
2: echo DB-Server > /proc/sys/kernel/hostname --运行后立即生效(新会话生效),但是在系统重启后会丢失所做的修改
3: sysctl kernel.hostname=DB-Server --运行后立即生效(新会话生效),但是在系统重启后会丢失所做的修改
4: 修改/etc/sysconfig/network下的HOSTNAME变量 --需要重启生效,永久性修改。
https://www.cnblogs.com/kerrycode/p/3595724.html
Redhat7
hostnamectl 永久修改 立即生效 不需要重新启动
[root@liwm ~]# hostnamectl set-hostname riyimei
[root@liwm ~]# bash
[root@riyimei ~]#
[root@riyimei ~]# hostnamectl
Static hostname: riyimei
Icon name: computer-vm
Chassis: vm
Machine ID: a1c014c347ec4c488de145182244a866
Boot ID: 2457355e31dd45b7badc9294f02ef562
Virtualization: vmware
Operating System: CentOS Linux 8 (Core)
CPE OS Name: cpe:/o:centos:centos:8
Kernel: Linux 4.18.0-147.el8.x86_64
Architecture: x86-64
[root@riyimei ~]#
下一篇:iostat