Small knowledge, big challenge! This article is participating in the creation activity of “Essential Tips for Programmers”.
Su indicates switch user to switch the user
Su Switching users
The su command is used to switch users. The current user can switch to another user without logging out.
Switch from root to root_test:
[root@VM_0_15_centos ~]# su - root_testLast login: Thu Sep 2 11:36:30 CST 2021 from 58.211.xx.xx on PTS /1 [root_test@VM_0_15_centos ~]$Copy the code
Su – is different from su
Su – indicates a complete switch to the new user. That is, the environment variables and the current directory are changed to the information about the new user. The original information is not retained.
You are advised to use a minus sign (-) when switching user identities.
Password authentication is not required when you switch from root administrator to common user. However, switching between other users, or switching from other users to root, requires a password.
[root_test@VM_0_15_centos ~]$ su - root Password: Last login: Thu Sep 2 22:33:52 CST 2021 from 112.87. XXX on PTS /0 Last Failed login: Thu Sep 2 23:11:19 CST 2021 on pts/0 There were 21 failed login attempts since the last successful login. [root@VM_0_15_centos ~]#
Copy the code
You can also use exit to switch to another user.
Direct inputsu -
或 su
“Command, do not specify the user name, press Enter, the system will switch to the root user, in this case, enter the password of root.