Recently, I bought a virtual host and installed Ubuntu system, but the host name is not friendly.
For the perfect person, it’s annoying to see such an unrepresentative name.
How to change the host name ???
The answer is to use Linux hostname command.
About the hostname command
hostname – show or set the system’s host name
View current hostname
[email protected]:~# hostname
[email protected]:~# hostname ylspirit
Modify hostname, no need to restart, new session takes effect, restart los.
How to modify the hostname permanently ???
About the /etc/hostname file
This file stores the name of the hostname of the current host. Each time the system starts, it will get the name of the system by reading this file.
[email protected]:~$ vim /etc/hostname
# save and reboot system
About the /etc/hosts file
Network host name.
You can redirect the IP pointed to by the domain name by modifying the hosts file
Query the interface IP corresponding to the host name:
[email protected]:~# hostname -i