Command prompt [root@localhost ~]#Detailed

When you open the bash terminal, you will find a prompt similar to [root@localhost ~]# at the top of the entire screen. The meaning is as follows:
1. root means that the user is root and
can be replaced by the su username command, which will be demonstrated later.
2.@ is the connector, the fixed format
3.localhost is the host name of the current computer.
View through the hostname command, the default host name of redhat and centos is localhost.localdomain

[root@localhost ~]#hostname
localhost.localdomain

4. ~ is the home directory of the current user. The home directory of the
root user is generally /root, which can be viewed through pwd

[root@localhost ~]# pwd
/root

5.# is the prompt for system administrator users, and the prompt for non-system administrator users is $

6. Demonstration
Based on the above content, let's switch users to see how the command prompt changes

[root@localhost ~]# su - hollowman
[hollowman@localhost ~]$

It can be found that the user has changed from root to hollowman
, and the prompt # has also changed to $. It
can be found that the current directory is still ~, which is the home directory of the current user (hollowman), because it is used in the switch user command "-", the role is to locate the directory to the current directory of the new user, pwd to check the directory changes:

[hollowman@localhost ~]$ pwd
/home/hollowman

The home directory of the hollowman user is /home/hollowman, and the home directories of general users are in /home/用户名this directory

7. Modify the host name

Sometimes we want to have our own system more personalized, and often need a host name, how to achieve it?
The linux hostname information is saved in the /etc/hostname file.
Method 1: Modify the /etc/hostname file directly and restart to take effect

[root@localhost ~]#echo "hollowman.cn"  > /etc/hostname
[root@localhost ~]#reboot

Method 2: hostnamectl set-hostname command is implemented, restart to take effect

[root@localhost ~]hostnamectl set-hostname hollowman.cn
[root@localhost ~]#reboot

Guess you like

Origin blog.csdn.net/ymz641/article/details/111473018