Home >Operation and Maintenance >Linux Operation and Maintenance >The role and practical application of host names in Linux systems
The role and practical application of the host name in the Linux system
In the Linux system, the hostname (hostname) is an extremely important concept, which is used to identify the network A host (computer) in . Hostnames are usually unique and can be used to identify different computers on a network. The setting of the host name has practical significance and can also improve the convenience of system management.
In the Linux system, you can use the following commands to view and modify the host name:
View host name
hostname
Temporarily modify the host name
hostname <new_hostname>
Permanently modify the hostname
##Debian/Ubuntu
In the/etc/hostname file Edit the host name in:
sudo nano /etc/hostnameThen restart the system or execute the following command to make the modification effective immediately:
sudo hostnamectl set-hostname <new_hostname>
CentOS/RHEL
Also edit the host name in the/etc/hostname file and execute the following command:
sudo hostnamectl set-hostname <new_hostname> sudo systemctl restart systemd-hostnamed
/etc/hosts file. This file is mainly used to resolve the relationship between host names and IP addresses locally. In this file, you can manually add the mapping between host names and IP addresses to facilitate local host name resolution.
/etc/hosts file:
127.0.0.1 myhostnameIn this way, when
myhostname is requested locally, the system will automatically resolve it The address is
127.0.0.1.
/etc/hosts file, the mapping of host names and IP addresses can be more flexibly performed.
The above is the detailed content of The role and practical application of host names in Linux systems. For more information, please follow other related articles on the PHP Chinese website!