How to modify the Linux hostname

How to modify the Linux hostname

You can use the hostname command to modify the Linux host name, but this method is only a temporary modification and will become invalid after restarting the machine. Permanently modify the host name by editing the /etc/sysconfig/network file.

1. Temporarily modify the host name

1. Check the host name

[root@wgx ~]# hostname
wgx.oracle

2. Modify the host name

[root@wgx ~]# hostname oracle.example.com
[root@wgx ~]# hostname
oracle.example.com

2. Permanently modify the host name

[root@wgx ~]# vim /etc/sysconfig/network

NETWORKING=yes
HOSTNAME=oracle.example.com

After editing the /etc/sysconfig/network file, you need to restart the system to take effect. If you don't want to restart the system, you can use hostname to make temporary changes, and set the host name in the configuration file to be the same as the host name set by the hostname command. This way you can avoid restarting the host.

Guess you like

Origin blog.csdn.net/weixin_44377973/article/details/105560907