Ubuntu modifies the hostname of this machine

Source: Internet
Author: User

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

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.