How to modify the host name (hostname) under Linux

Source: Internet
Author: User
Tags command line

At the Linux command line, enter hostname, view the current hostname, and if you want to modify it, add a new host name directly after hostname (note: The following actions require root user execution), such as:

# hostname Newhostname

Note, however, that the above hostname command only temporarily modifies the hostname and fails after reboot. If you want to permanently change the host name, you must edit the following file:

Vi/etc/sysconfig/network

Hostname=yournewhostname

After this operation, the new hostname remains in effect even after the reboot.

Finally, after the host name has been modified, remember to configure the new hostname and IP match in the/etc/hosts file, such as:

Vi/etc/hosts

192.168.1.16 hostname Alias

The first field is an IP address, the second is a formal hostname (returned by the hostname command), and the other fields are aliases

See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/Servers/web/

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.