Get the App
SLTechnology News&Howtos  ›  Servers  › 

RHEL7.x version, 3 ways to modify hostname

Shulou Source: shulou.com Published: 2022-06-03 09:11:10 12月06日 Update

RHEL7.x no longer uses / etc/sysconfig/network as the configuration file for the hostname, but uses the / etc/hostname file instead, so how do you set the hostname in RHEL7.x? Three ways to set up are described below.

Method 1:

Modify the / etc/hostname file, after which the bash command takes effect.

[root@localhost /] # vim / etc/hostname [root@localhost /] # bash [root@ys /] #

Method 2:

Use the hostnamectl command, and after modification, the bash command takes effect.

[root@localhost /] # hostnamectl set-hostname ys / / set the hostname to ys [root@localhost /] # bash [root@ys /] #

Method 3:

Use the nmcli command to restart systemd-hostnamed.service to take effect after modification

Root@localhost /] # nmcli general hostname ys / / set the hostname to ys [root@localhost /] # nmcli general hostname / / View the current hostname ys [root@localhost /] # systemctl restart systemd-hostnamed.service / / restart to make it effective

Tags: Host method command file configuration but middle version Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information Shulou Technology Huawei NVidia Apple