CENTOS 7.0 Change hostname

Source: Internet
Author: User

In Centos/rhel 7, there is a command-line tool called Hostnamectl, which allows you to view or modify the configuration associated with a host name.

To view the host name-related settings:

$ HOSTNAMECTL Status

View only static, transient, or flexible hostname, using "--static", "--transient" or "--pretty" options, respectively.

$ hostnamectl Status [--static|--transient|--pretty]


To modify all three host names at the same time: static, transient, and flexible hostname: change to www


$ sudo hostnamectl set-hostname "www"


Set the/etc/hosts to save the changes, or the restart will fail.

If you only want to modify a specific hostname (static, transient or flexible), you can use the "--static", "--transient" or "--pretty" option.

For example, to permanently modify a host name, you can modify the static hostname:

You do not have to restart the machine to activate the permanent hostname modification. This command modifies the kernel host name immediately.

$ sudo hostnamectl--static set-hostname

CENTOS 7.0 Change hostname

Related Article

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.