RHEL 7/CentOS 7 has changed from the previous method of modifying the hostname, for example, CentOS modification/etc/sysconfig/network takes effect after restart. There are two ways to quickly modify the host name.
Method 1:
Hostnamectl is used to query and modify system settings. For more information about the usage, see online help.
[Root @ idoseek ~] # Hostnamectl set-hostname idoseek.com
[Root @ idoseek ~] # Hostnamectl
Static hostname: www.111cn.net
Icon name: computer-vm
Chassis: vm
Machine ID: fd8cf26e06e411e4a9d004010897bd01
Boot ID: 7f8dbd4c029c470ebbbd7d72ac53a678
Virtualization: kvm
Operating System: CentOS Linux 7 (Core)
Cpe OS Name: cpe:/o: centos: 7
Kernel: Linux 3.10.0-123. el7.x86 _ 64
Architecture: x86_64
[Root @ idoseek ~] #
Method 2:
Temporary modification. After exiting, the logon takes effect. After restarting, the modification becomes invalid:
[Root @ idoseek ~] # Hostname www.111cn.net
Permanent modification of host name:
[Root @ idoseek ~] # Vim/etc/hostname
Idoseek.com