Permanently modify hostname without restarting under Linux

Permanently modify the hostname without restarting under Linux
1. If you only modify the hostname, you can use the following command
hostname newHostname 
Note: This modification method is only valid currently, and the hostname will become invalid after the server restarts and return to the original hostname.
2. If you need to permanently modify the hostname, you can use the following command
vi /etc/sysconfig/network 
to modify the HOSTNAME item, but this method needs to be restarted to take effect.
3. Therefore, the way to permanently modify the hostname without restarting is to combine the above two, so that it can take effect at present without restarting, and it will also take effect after restarting.


On the 192.168.1.200 machine, lxy can also be set to
NETWORKING=yes
HOSTNAME=localhost.localdomain
HOSTNAME=redmooc.com
HOSTNAME=mooc.com

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326180130&siteId=291194637