How Linux modifies host names

Source: Internet
Author: User
Tags visibility

Linux is usually installed at the time, the user needs to set the hostname, but in daily use, convenient grouping or memory, etc., may need to modify the host name, modify the hostname has 2 kinds, temporary modification or permanent modification, the following are described separately.

First, temporarily modify the host name
    1. Temporary modification is only valid at this time, and will return to the original hostname after the next reboot.

      In terminal input: hostname xxxxx, where xxxxx is the hostname that needs to be changed

    2. After the return, the hostname has changed, but the interface is the original hostname, at this time you can exit login exit, to refresh the host name.
    3. After the reboot, the hostname will be restored to the original host name.

Second, permanently modify the host name

1, log in as root, or log on to the root user, and then enter the hostname command at the prompt, you can see the current system host name is Localhost.localdomain.

2. Change the network file under/etc/sysconfig, enter vi/etc/sysconfig/network at the prompt, and change the value after hostname to the host name you want to set.

3. Change the Hosts file under/etc, enter vi/etc/hosts at the prompt and change the localhost.localdomain to the host name you want to set.

4. Restart the server by entering the reboot command at the prompt.

5, restart after the completion of the hostname command query system hostname, you can see the system hostname has been changed to MyComputer.

How Linux modifies host names

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.