Home > Article > Operation and Maintenance > 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.
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.
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
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!