Home  >  Article  >  Operation and Maintenance  >  How to check the host name in linux

How to check the host name in linux

藏色散人
藏色散人Original
2020-02-08 10:33:4422400browse

How to check the host name in linux

How to check the host name in Linux?

View host name

Recommended: "Linux Tutorial"

1. You can use the hostnamctl command.

2. hostnamectl.

                                                                            How to check the host name in linux

Extended information:

Change the hostname (hostname) of the Linux system

This is achieved by modifying the configuration file.

The host name is saved in the /etc/hostname file, so we can open this file and manually edit the host name.

sudo nano /etc/hosts12

Delete the old host name, replace it with the new host name, and save the file. Pay attention to capitalization.

How to check the host name in linux

If you do not update the /etc/hosts file, then some programs, such as sudo, do not know how to resolve the new host name.

If you are changing the host name of the Linux server, the new host name should be resolved to the public IP of the Linux server. If you change the hostname of your PC, the new hostname should resolve to 127.0.0.1, or 127.0.1.1.

127.0.1.1 is the IP of the local host resolved by the Debian Linux distribution. When the Debian system is installed, if the computer's IP is dynamic, the Debian installation program will create the 127.0.1.1 entry in the /etc/hosts file. The 127.0.1.1 address uses the loopback network card. In fact, 127.0.0.0/8 (127.0.0.0 ~ 127.255.255.255) all use the loopback network card.

The above is the detailed content of How to check the host name in linux. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn