Study notes: UOS server changes host name

UOS server view host name

hostnamectl

or

hostname

UOS server changes host name

hostnamectl set-hostname <新的主机名>

or

hostname -b <新的主机名>

Note: hostnamectl can display and modify the static host name (permanent modification). hostname displays and modifies the dynamic host name. After the computer is restarted, it will return to the original host name.
The hostnamectl command will modify the /etc/hostname file, which stores the hostname.
In addition, the files related to the host name include the /etc/hosts file, which configures domain name mapping. For example, it is best to change the location of Research-PC in the second line of the file below to the new host name. If this is not changed, the prompt "sudo: Unable to resolve host: XXX: There is no address associated with the host name" will be prompted when sudoing.

127.0.0.1       localhost
127.0.1.1 Research-PC

# The following lines are desirable for IPv6 capable hosts
::1     localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

reference

3 ways to change the hostname of your Linux system (hostname)

Guess you like

Origin blog.csdn.net/sinat_37014456/article/details/118052301
Recommended