Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

RHEL7.x version, 3 ways to modify hostname

2025-04-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

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

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report