In the Ubuntu system, there are several ways to quickly view the hostname:
One, open a GNOME terminal window, you can see the host name at the command prompt, the hostname is usually after the "@" symbol;
Second, enter the command in the terminal window: hostname or UNAME–N, you can view the host name of the current host.
3. Permanently modify the host name
Command line Run command: "hostname new host name"
Where "new host name" can be represented by any valid string. In this way, however, the new hostname is not saved in the system, and the host name reverts to the original hostname after rebooting the system.
Example: hostname ubuntu-temp
So the host name is temporarily modified to ubuntu-temp, but the terminal will not immediately display the host name after the effective, re-open a terminal window (SSH connection to the terminal need to reconnect to be able);
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.
Exit // Re-login
The value indicates that not all/etc/hostname files exist in other Linux distributions. such as the Fedora,centos release, host names are stored in the /etc/sysconfig/network file. Therefore, you should be aware of what kind of Linux distribution you should make when you modify the host name.
3. The difference between/etc/hostname and/etc/hosts
/etc/hostname is a host name, an example of a hostname file:
/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:
Ubuntu,centos Permanent modification of host names