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 is the specific method of modifying hostname in Linux system

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

Share

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

The editor today takes you to understand what is the specific method of modifying the host name of the Linux system. The knowledge points in the article are introduced in great detail. Friends who feel helpful can browse the content of the article together with the editor, hoping to help more friends who want to solve this problem to find the answer to the problem. Let's follow the editor to learn more about "what is the specific method of modifying the host name of the Linux system".

How does the Linux system change the host name?

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 delete the old hostname, replace it with the new hostname, and save 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 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 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 is Linux system Linux is a free-to-use and free-spread UNIX-like operating system, is a POSIX-based multi-user, multi-task, multi-threaded and multi-CPU operating system, using Linux can run major Unix tools, applications and network protocols.

Thank you for your reading, the above is the whole content of "what is the specific method for Linux system to modify the host name?" learn friends to hurry up to operate it. I believe that the editor will certainly bring you better quality articles. Thank you for your support to 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