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 view and modify hostname under Linux

2025-04-11 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

Editor to share with you how to view and modify hostname under Linux, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

Hostname is the hostname used to identify a machine in the system. After logging in to the linux system, [root@izm5e9z5o9dc8yjs3vh6mhz], where @ is followed by the host name, you can determine the landing system by the host name.

Query hostname:

Uname-n

Hostname

[root@oldboy ~] # uname-noldboy [root@oldboy ~] # hostnameoldboy

The hostname of the Linux operating system is a kernel variable, and you can view the native hostname through the hostname command. You can also view it directly by cat / proc/sys/kernel/hostname.

[root@oldboy ~] # hostnameoldboy [root@oldboy ~] # cat / proc/sys/kernel/hostnameoldboy

The above two outputs have the same result.

Modify the hostname of the runtime Linux system, that is, there is no need to restart the system

The hostname command can set the hostname of the system, which takes effect immediately after running, but the changes will be lost after the system is rebooted. If you want to permanently change the hostname of the system, you need to modify the relevant settings file.

Set the hostname:

Temporary effect:

The default is to display the hostname set the hostname: hostname hostname

Hostname displays and sets hostname

Permanent effect:

Vim / etc/sysconfig/network; modifies hostname to the expected value; save and exit.

/ etc/sysconfig/network

Vim / etc/hosts; modifies or adds hostname, the IP address corresponding to the hostname. Save and exit.

/ etc/hosts

The service network restart; network restarts.

The above is all the contents of the article "how to View and modify hostname under Linux". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

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

Development

Wechat

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

12
Report