Home >Operation and Maintenance >Linux Operation and Maintenance >Linux permanently changes host name
Recommended tutorial: linux tutorial
How to modify Linux Your own host name
If you want to change your own host name, you can follow the steps below
Use hostname
Using the hostname
command can only temporarily change our host name. When we restart, the host name will be restored to the original
# hostname newhostname
Enter hostname linux
You can change the host name to linux, use the uname -n
command to view
At this time our host name has changed, left Why is it still Peithon
? Try reopening a terminal, or if using Xshell, reopen the session
Modify the configuration file
If you want to permanently change your host name, you must follow the steps below
Modify the file/etc/sysconfig/network
<img src="https://img.php.cn/upload/image/752/322/987/1563866846841951.png" title="1563866846841951.png" alt="Linux permanently changes host name">
Mylinux is the host name to be set, then save and exit. Restart the system and you will read the configuration file and set the host name to the new hostname.
If you don’t want to restart the system at this step, you can use hostname mylinux
to make temporary modifications. In this way, even if the system is restarted, the hostname set in the read configuration file is the same as your hostname setting. The same, which is equivalent to unchanged
In this way, the setting of the host name is completed
The above is the detailed content of Linux permanently changes host name. For more information, please follow other related articles on the PHP Chinese website!