CentOS7 modify host name

Source: Internet
Author: User
In CentOS or RHEL, there are three defined host names: a, static (static), B, transient (transient), and c, flexible (pretty ). & Ldquo; static & rdquo; host name is also called the kernel host name. it is the host name automatically initialized from/etc/hostname at startup. & Ldquo; transient & rdquo; host names are temporarily assigned when the system is running, for example, allocated through DHCP or mDNS servers. Static host name and transient master

In CentOS or RHEL, there are three defined host names: a, static (static), B, transient (transient), and c, flexible (pretty ). The "static" host name is also called the kernel host name. it is the host name automatically initialized from/etc/hostname at startup. The "transient" host name is a temporary host name allocated during system operation, such as through DHCP or mDNS server. Both the static host name and the transient host name follow the same character restriction rules as the Internet domain name. On the other hand, "flexible" host names allow the use of free-form (including special/blank characters) host names to be displayed to end users (such as Dan's Computer ).

In CentOS/RHEL 7, a command line tool named hostnamectl allows you to view or modify host name-related configurations.

To view host name settings:

$ hostnamectl status

Only view static, transient, or flexible host names. use the "-- static", "-- transient", or "-- pretty" options respectively.

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

You need to modify all three host names at the same time: static, transient, and flexible host names:

$ sudo hostnamectl set-hostname 
 

As shown above, when modifying static/transient host names, any special or blank characters are removed, and any uppercase letters in the provided parameters are automatically converted to lowercase letters. Once the static host name is modified,/etc/hostname will be automatically updated. However,/etc/hosts will not be updated to save the changes, so you need to manually update/etc/hosts.

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

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

$ sudo hostnamectl --static set-hostname 
 

Note that you do not have to restart the machine to activate permanent host name modification. The preceding command immediately modifies the kernel host name. After logging out and logging on again, you will be prompted on the command line to observe the new static host name.

Via: http://ask.xmodulo.com/change-hostname-centos-rhel-7.html

Translator: GOLinux proofreader: Caroline

This article was originally translated by LCTT and launched with the Linux honor in China

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.