After Linux is installed, its default host name is localhost. Changing the Linux hostname requires 3 steps.
1. Use hostname to modify the current host name.
hostname new-hostname
2. Modify the /etc/sysconfig/network configuration file so that the new hostname can be used the next time you restart.
Open the /etc/sysconfig/network file and modify HOSTNAME=new-hostname.domainname.
The modified /etc/sysconfig/network file is as follows:
NETWORKING=yes
HOSTNAME=new-hostname.localdomain
3. Modify this The machine's domain name resolution file /etc/hosts enables the local application to resolve the new host name.
Edit file: /etc/hosts
Modify: xxx.xxx.xxx.xxx new-hostname.domainname new-hostname
(xxx here represents the local computer) The network address can also be the loopback address 127.0.0.1)
The modified /etc/hosts file is as follows:
127.0.0.1 localhost.localdomain localhost
127.0. 0.1 new-hostname.localdomain new-hostname
WORK
The above is the detailed content of Linux host name modification trilogy. For more information, please follow other related articles on the PHP Chinese website!