In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces the relevant knowledge of how to modify hostname under Linux, the content is detailed and easy to understand, the operation is simple and fast, and it has a certain reference value. I believe you will gain something after reading this Linux article on how to modify hostname. Let's take a look at it.
The hostname of the Linux operating system is a kernel variable, and you can view the native hostname through the hostname command. You can also view it directly on cat / proc/sys/kernel/hostname. This article focuses on how to modify hostname under Linux.
View the current hostname
First we use the hostname command to see the current hostname.
Hostname1
You can also use the hostnamctl command
Hostnamectl1
Write the picture description method 1: modify the configuration file
The hostname is saved in the / etc/hostname file, so we can open the file and edit the hostname manually.
Sudo nano / etc/hosts12
Delete the old hostname, replace it with the new hostname, and save the file. Pay attention to upper and lower case.
Write the picture description here.
If you don't update the / etc/hosts file, some programs, such as sudo, don't know how to parse the new hostname.
If you are changing the hostname of the Linux server, the new hostname should resolve to the public IP of the Linux server. If you change the hostname of the PC, the new hostname should resolve to 127.0.0.1, or 127.0.1.1.
127.0.1.1 is the IP that the Debian Linux distribution parses the local host. When the Debian system is installed, if the computer's IP is dynamic, the Debian installer creates an entry of 127.0.1.1 in the / etc/hosts file. The 127.0.1.1 address uses the loopback network card. In fact, 127.0.0.0Mab 8 (127.0.0.0 ~ 127.255.255.255) uses the loopback network card.
Method 2:hostnamectl command
The command syntax is:
Sudo hostnamectl set-hostname 12
This command removes the hostname from the / etc/hostname file and replaces it with the new hostname. As with the first method, we also need to update the / etc/hosts file. The essence of both methods is the same.
Method 3:hostname command to make temporary changes
If you only need to change the hostname temporarily, you can use the hostname command.
Sudo hostname 12
This command does not change the static hostname (static hostname) in the / etc/hostname file, it only changes the temporary hostname (transient hostname). So when you restart the computer, you go back to the old hostname.
The static hostname is saved in the / etc/hostname file.
This is the end of the article on "how to modify hostname under Linux". Thank you for reading! I believe you all have a certain understanding of the knowledge of "how to modify hostname under Linux". If you want to learn more, 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.