In the Ubuntu system, the host name setting involves two files:
/etc/hostname:hostname settings
/etc/hosts:hostname <=> IP Address correspondence
1. View Host Name
It can be viewed through hostname, or through uname-n.
2. Temporarily modify host name
Command line Run command: "hostname new host name"
Example: hostname email.jd.com
In this way, the new hostname is not saved in the system, and the host name reverts to the original hostname after rebooting the system.
3. Permanently modify the host name
It is also easier to permanently modify the hostname in the Ubuntu system. Host name in the/etc/hostname file, modify the host name, edit the hostname file, enter a new hostname in the file and save the file. After rebooting the system, refer to the Quick View hostname method described above to confirm that the hostname has been successfully modified.
3. The difference between/etc/hostname and/etc/hosts
The host name is stored in the/etc/hostname
An example of a hostname file: email.jd.com
/etc/hosts storage is the domain name and IP correspondence, the domain name and hostname do not have any relationship, you can specify any one of the IP name, hostname file An example:
127.0.0.1 localhost
127.0.1.1 email.jd.com
Ubuntu modifies the hostname of this machine