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

The method of temporarily or permanently modifying hostname by ubuntu

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

The current ubuntu version is 14.04:

View hostname

After connecting to ubuntu through the GNOME terminal, you can see the hostname directly from the command prompt, usually after the @ symbol, such as: root@myvs10d31. You can also view the hostname in the terminal with the command: hostname or uname-n.

Temporarily modify hostname

To change the hostname temporarily, run hostname new_hostname from the command line

Where new_hostname can be represented by any legal character. However, this modification is only temporary, and after rebooting the system, hostname will return to its original one. Moreover, after the modification, the current terminal will not take effect immediately, and a terminal window needs to be reopened.

Permanently modify hostname

The ubuntu system only needs to modify the / etc/hostname file to permanently modify the hostname. For other linux distributions, hostname exists in / etc/sysconfig/network, so it is necessary to distinguish between linux distributions when modifying hostname.

Root@myvs10d31:~# vim / etc/hostname myvs10d31

After modifying the hostname, it is recommended to modify / etc/hosts at the same time:

Root@myvs10d31:~# vim / etc/hosts127.0.0.1 localhost127.0.1.1 myvs10d31

/ etc/hosts stores the correspondence between domain name and ip. There is no direct relationship between domain name and host name. You can specify any corresponding name for an ip, but it is recommended to resolve an ip corresponding to hostname.

The above is the whole content of this article, I hope it will be helpful to your study, and I also hope that you will support it.

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