Home  >  Article  >  Operation and Maintenance  >  Linux host name modification command

Linux host name modification command

angryTom
angryTomOriginal
2020-02-06 09:39:2212471browse

Linux host name modification command

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!

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
Previous article:How to check IP in LinuxNext article:How to check IP in Linux