In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article is about how CentOS or RHEL 7 modifies host names. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
Question: what is the correct way to change the hostname on CentOS/RHEL 7 (permanent or temporary)?
In CentOS or RHEL, there are three defined hostnames:
A. static (static)
B, transient (transient)
C, flexible (pretty)
The "static" hostname, also known as the kernel hostname, is the hostname that the system initializes automatically from / etc/hostname at startup. The "transient" hostname is a hostname temporarily assigned while the system is running, for example, through a DHCP or mDNS server. Both static and transient hostnames follow the same character restrictions as Internet domain names. "flexible" hostnames, on the other hand, allow the use of free-form hostnames (including special / white space characters) to be presented to end users, such as Dan's Computer.
In CentOS/RHEL 7, there is a command-line tool called hostnamectl that allows you to view or modify configurations related to hostnames.
To view settings related to the hostname:
$hostnamectl status
View only static, transient, or flexible hostnames, using the "--static", "--transient", or "--pretty" options, respectively.
$hostnamectl status [--static |-- transient |-- pretty]
To modify all three hostnames at once: static, transient, and flexible hostnames:
$sudo hostnamectl set-hostname
As shown above, when you modify a static / transient hostname, any special or white space characters are removed, and any uppercase letters in the supplied parameters are automatically converted to lowercase. Once the static hostname is modified, / etc/hostname will be updated automatically. However, / etc/hosts will not be updated to save your changes, so you need to update / etc/hosts manually.
If you only want to change a specific hostname (static, transient, or flexible), you can use the "--static", "--transient" or "--pretty" options.
For example, to permanently change the hostname, you can modify the static hostname:
$sudo hostnamectl-staticset-hostname
Note that you do not have to restart the machine to activate permanent hostname modification. The above command immediately modifies the kernel hostname. Log out and log back in to observe the new static hostname at the command line prompt.
Thank you for reading! This is the end of the article on "how to modify the host name of CentOS or RHEL 7". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.