Ubuntu,centos Permanent modification of host names

Source: Internet
Author: User

1. View Host Name


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.


2, temporarily modify the host name (root user login can only)


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);

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.

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:
V-jiwan-ubuntu-temp

/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 V-jiwan-ubuntu

Ubuntu,centos Permanent modification of host names

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.