Linux host name modification command
1. If you only need to temporarily change the host name, you can use the hostname command.
sudo hostname <new-hostname> # 例如: sudo hostname myDebian
This command will not change the static hostname (static hostname) in the /etc/hostname file, it only changes the temporary hostname (transient hostname). So after restarting the computer it will go back to the old hostname.
2. If you want to permanently change the host name, you can use the hostnamectl command, or use vim to manually modify the /etc/hostname file
command syntax For:
sudo hostnamectl set-hostname <newhostname> # sudo vim /etc/hostname
This command will delete the host name in the /etc/hostname file and replace it with the new host name.
(Online video tutorial sharing: linux video tutorial)
The above is the detailed content of Linux host name modification command. For more information, please follow other related articles on the PHP Chinese website!