In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
In this issue, the editor will bring you about how to modify the host name in CentOS 7. The article is rich in content and analyzes and narrates it from a professional point of view. I hope you can get something after reading this article.
How to modify the hostname on CentOS 7
In CentOS, there are three defined hostnames: static, transient, and pretty. The "static" hostname, also known as the kernel hostname, is the hostname that the system initializes automatically from / etc/hostname at startup. "transient" hostnames are hostnames temporarily assigned while the system is running, for example, through DHCP or mDNS servers. 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 Linuxidc.
In CentOS 7, there is a command-line tool called hostnamectl that allows you to view or modify configurations related to hostnames.
1. To view settings related to the hostname:
[root@localhost ~] # hostnamectl
Static hostname: localhost.localdomain
Icon name: computer
Chassis: n/a
Machine ID: 80a4fa4970614cf6be9597ecd6f097a9
Boot ID: 28420e272e1847a583718262758bd0f7
Virtualization: vmware
Operating System: CentOS Linux 7 (Core)
CPE OS Name: cpe:/o:centos:centos:7
Kernel: Linux 3.10.0-123.el7.x86_64
Architecture: x86_64
Or
[root@localhost ~] # hostnamectl status
Static hostname: localhost.localdomain
Icon name: computer
Chassis: n/a
Machine ID: 80a4fa4970614cf6be9597ecd6f097a9
Boot ID: 28420e272e1847a583718262758bd0f7
Virtualization: vmware
Operating System: CentOS Linux 7 (Core)
CPE OS Name: cpe:/o:centos:centos:7
Kernel: Linux 3.10.0-123.el7.x86_64
Architecture: x86_64
two。 View only static, transient, or flexible hostnames, using the "--static", "--transient", or "--pretty" options, respectively.
[root@localhost] # hostnamectl-- static
Localhost.localdomain
[root@localhost] # hostnamectl-- transient
Localhost.localdomain
[root@localhost] # hostnamectl-- pretty
3. To modify all three hostnames at once: static, transient, and flexible hostnames:
[root@localhost ~] # hostnamectl set-hostname Linuxidc
[root@localhost] # hostnamectl-- pretty
Linuxidc
[root@localhost] # hostnamectl-- static
Linuxidc
[root@localhost] # hostnamectl-- transient
Linuxidc
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 be sure to manually update / etc/hosts every time you change the hostname, and then restart CentOS 7. Otherwise, the system will be slow to restart.
4. Manual update / etc/hosts
Vim / etc/hosts
127.0.0.1 Linuxidc hunk_zhu
# 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain
:: 1 localhost localhost.localdomain localhost6 localhost6.localdomai
5. After restarting CentOS 7 (reboot-f)
[root@Linuxidc ~] # hostname
Linuxidc
[root@hunk_zhu] # hostnamectl-- transient
Linuxidc
[root@hunk_zhu] # hostnamectl-- static
Linuxidc
[root@hunk_zhu] # hostnamectl-- pretty
Linuxidc
6. 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:
[root@localhost] # hostnamectl-- static set-hostname Linuxidc
After restarting CentOS 7 (reboot-f)
[root@Linuxidc] # hostnamectl-- static
Linuxidc
[root@Hunk_zhu] # hostnamectl-- transient
Linuxidc
[root@Hunk_zhu] # hostnamectl-- pretty
Linuxidc
[root@Hunk_zhu ~] # hostname
This is how to modify the host name in CentOS 7 shared by the editor. If you happen to have similar doubts, you might as well refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.