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

How to modify the hostname on CentOS

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

Share

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

This article focuses on "how to modify the host name on CentOS". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to change the host name on CentOS.

There are two changes that need to be made: one is / etc/sysconfig/network and the other is / etc/hosts. Changing only one of them will cause the system to start abnormally. First switch to the root user.

The code is as follows:

/ etc/sysconfig/network

Open the file with a line of HOSTNAME=localhost.localdomain (if default) in any editor you like, and change localhost.localdomain to your hostname.

The code is as follows:

/ etc/hosts

Open the file and you will have a line of 127.0.0.1 localhost.localdomain localhost. Where 127.0.0.1 is the local loop address and localhost.localdomain is the host name (hostname), which is what you want to modify. Localhost is an alias for the host name (alias), which appears at the Konsole prompt. Change the second item to your hostname, and the third option is optional.

After the above two files have been modified, they will not take effect immediately. If you want to take effect immediately, you can use hostname your-hostname to make temporary changes, it only temporarily changes the hostname, and the system will return to its original state after reboot. But modifying the above two files is permanent, and rebooting the system will get a new hostname.

Finally, check the hostname uname-n after reboot.

At this point, I believe you have a deeper understanding of "how to modify the host name on CentOS". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

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