编程知识 cdmana.com

[Linux] modify the host name under Linux - three simple steps


I bought one at Alibaba cloud Linux The server , But root The user name turns out to be a product ID, It's not good to use .

How to change the user name , Here are three simple steps .

One 、

With root The user login , Or log in and switch to root user 、

Input... At the terminal : hostname The current host name is displayed .

【Linux】Linux Next, change the host name - Simple three-step solution _ Host name

Input vi /etc/sysconfig/network, And then HOSTNAME= Change the following value to the host name you want to set .

【Linux】Linux Next, change the host name - Simple three-step solution _root user _02

Two 、

change /etc Under the hosts file , Enter at the prompt vi /etc/hosts, And then localhost.localdomain( It could be something else , Please find the corresponding position according to the picture , Here for me chenhaoxiang) Change to the host name you want to set .

【Linux】Linux Next, change the host name - Simple three-step solution _linux_03

3、 ... and 、

Input reboot command , Restart the server .

Log in after reboot , Input again hostname View host name !

To sum up, the core command above is :

      
      
vi /etc/sysconfig/network
vi /etc/hosts
reboot
  • 1.
  • 2.
  • 3.

author : Familiar with memory , All rights reserved .

Welcome to reprint , Sharing is the source of progress .



版权声明
本文为[51CTO]所创,转载请带上原文链接,感谢
https://cdmana.com/2022/134/202205141232025728.html

Scroll to Top