Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the three methods of changing hostname in Linux system?

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly analyzes the relevant knowledge of what the three methods of changing host name in Linux system are, the content is detailed and easy to understand, the operation details are reasonable, and has a certain reference value. If you are interested, you might as well follow the editor to have a look, and follow the editor to learn more about "what are the three ways to change the host name in the Linux system?"

The hostname is the label assigned to the machine to identify the computer on the network. Each device in the network should have a unique hostname. So how do I change the hostname in the Linux system?

The concrete method of changing host name in Linux system

To see the current hostname, first let's use the hostname command to see the current hostname.

Hostname1 can also use the hostnamctl command

Hostnamectl1

Method 1: modify the configuration file hostname and save it in / etc/hostname file, so we can open this file and edit the hostname manually.

Sudo nano / etc/hosts 12 removes the old hostname, replaces it with the new hostname, and saves the file. Pay attention to upper and lower case.

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.

The method 2:hostnamectl command command syntax is:

The command sudo hostnamectl set-hostname 12 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.

The command sudo hostname 12 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.

What are the versions of Linux? the versions of Linux are Deepin, UbuntuKylin, Manjaro, LinuxMint, Ubuntu and so on. Among them, Deepin is one of the best-developed Linux distributions in China; UbuntuKylin is a derivative release based on Ubuntu; Manjaro is a Linux release based on Arch; LinuxMint's default Cinnamon desktop is similar to Windows XP's easy-to-use; Ubuntu is the Linux operating system based on desktop applications.

On the "Linux system to change the host name of the three methods are what are" introduced here, more related content can be searched for previous articles, hope to help you answer questions, please support the website!

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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report