Linux host name Modification
GuideIn a LAN, each machine has a host name, which facilitates the distinction between the host and the host. Therefore, you can set a host name for each machine to access each other easily. For example, we can name each machine based on its functions in the LAN.
View host name commands[root@tonyx ~]# uname -ntonyx[root@tonyx ~]# hostnametonyx
Use the hostname commandCommand Format: hostname newhostname
Modify the host name temporarily, log out with the logout command, and log on again to take effect. But it does not take effect permanently.
Modify through the configuration file/etc/sysconfig/networkModify the configuration file. The linux host name will take effect after the next restart. If the configuration file takes effect permanently, use the hostname command.
[root@tonyx ~]# cat /etc/sysconfig/networkNETWORKING=yesHOSTNAME=tonyxu
File/etc/hosts FunctionsA row of this file corresponds to a comparison. The format of each row is:
The alias of the ip global host name.
This section compares ip addresses and host names ., You can associate some common website domain names with their corresponding IP addresses to a database, the system will first automatically find the corresponding IP address from the Hosts file. Once found, the system will immediately open the corresponding webpage, which is equivalent to DNS resolution.
For example, if the ip address of baidu is 220.181.57.217, you can add a line at the end of the file:
[root@tonyx ~]# cat /etc/hosts127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4::1 localhost localhost.localdomain localhost6 localhost6.localdomain6220.181.57.217 baidu.com
Address: http://www.linuxprobe.com/