Http://www.33lc.com/article/4015.html
1. view the Host Name
In Ubuntu, there are multiple methods to quickly view the Host Name:
1. Open a GNOME terminal window and you can see the host name in the command prompt. The host name is usually located after the "@" symbol;
2. Enter the hostname or uname-n command in the terminal window to view the Host Name of the current host.
2. Temporarily modify the Host Name
Run the following command on the command line: "hostname new host name"
The "New Host Name" can be expressed by any valid string. However, in this way, the new host name is not stored in the system. After the system is restarted, the host name will be restored to the original host name.
Example: hostname ubuntu-temp
In this way, the host name will be changed to ubuntu-temp temporarily, but the host name will not be immediately displayed in the terminal, and a terminal window will be re-opened (the terminal connected through ssh needs to be re-connected );
3. Change the host name permanently.
It is also easy to change the host name permanently in Ubuntu. The host name is stored in the/etc/hostname file. When modifying the host name, edit the hostname file, enter a new host name in the file, and save the file. After the system is restarted, check whether the host name is successfully modified by referring to the method described above to quickly check the host name.
Value indicates that not all other Linux distributions have the/etc/hostname file. For example, the ora release stores the host name in the/etc/sysconfig/network file. Therefore, when modifying the host name, you should be aware of the Linux release.
3. Differences between/etc/hostname and/etc/hosts
The host name is stored in/etc/hostname. An example of the hostname file is as follows:
V-jiwan-ubuntu-temp
/Etc/hosts stores the correspondence between the domain name and the ip address. The domain name and the host name are irrelevant. You can specify any name for any IP address. An example of the hostname file is as follows:
127.0.0.1 localhost
127.0.1.1 v-jiwan-ubuntu