1. View the current hostname
method 1:
1 2 |
|
Method 2: centos7 and above
1 2 3 4 5 6 7 8 9 10 11 |
|
2. Temporarily modify the host name
Temporary modification will not take effect after restarting the server
1 2 3 |
|
View the IP address corresponding to the machine name
1 2 |
|
3. Permanently modify the host name
Need to modify the following two configuration files
1. Method 1: Use hostnamectl command, applicable for contos7 and above
1 |
|
2. Method 2: Modify the configuration file /etc/hostname, save and exit
1 2 |
|
Note: The above two permanent modification methods need to restart the machine to take effect
1 |
|