Linux modifying host name -- a method that takes effect immediately

Dashatou Third Road 2022-01-26 12:47:32 阅读数:76

linux modifying host method takes

In the use of Linux Operating system process , If we want to change the host name , You can operate with the following commands

  1. View host name
[[email protected] ~]# hostname
  1. Modify hostname ,【myhost】 You can replace it with the host name you want
[[email protected] ~]# hostnamectl set-hostname **myhost**
  1. Check the hostname again
[[email protected] ~]# hostname
[[email protected] ~]# 

4. At this time, we can see that the host name displayed on the terminal is still the original
If you don't want to re-enter the terminal 、 restart 、 How to switch users , You can use the following method

Input... At the terminal 【bash】 command , Immediate effect

[[email protected] ~]# bash
[[email protected] ~]# 

The operation process is attached :
 Insert picture description here

copyright:author[Dashatou Third Road],Please bring the original link to reprint, thank you.