When the Inux is installed, its default hostname is localhost.
It takes 3 steps to modify the Linux host name:
1. Modify the current host name using hostname.
Hostname new-hostname
2. Modify the/etc/sysconfig/network configuration file so that the new hostname is used the next time you restart.
Open the/etc/sysconfig/network file and change the hostname to the following content.
Hostname=new-hostname.localdomain
3. Modify the local domain name resolution file/etc/hosts, so that the application of this machine can resolve the new host name.
Edit file:/etc/hosts
Modified: xxx.xxx.xxx.xxx new-hostname.domainname New-hostname
(XXX here on behalf of the local network address, can also be loopback address 127.0.0.1)
The modified/etc/hosts file is as follows:
127.0.0.1 localhost Localhost.localdomain
127.0.0.1 New-hostname New-hostname.localdomain
The reboot will take effect.