Skip to content

[Linux] Use “su” Command to Switch User

su is a very common command in Linux system, often used to switch users. At first I thought su was the abbreviation of switch user, but after searching, I discovered that it should be the abbreviation of substitute user.

So when do we use su? Most of the time, it is often used to elevate account permission: for example, it is to switch to the root account.


How to Use “su” Command

Switch to other account

The su command can be used to switch other accounts under the system. (Need to enter the password of the account)

su OTHER_ACCOUNT


But if you have super user permission, you can switch to another user directly.

sudo su OTHER_ACCOUNT



Switch to root account

If your has super user permission, you can use the following command to switch to the root account:

sudo su


If you have set a password for the root account in the system, you can directly use the following command, enter the password and switch to the root account:

su



Use “whoami” to check account name

If you want to confirm the account name after switching accounts, you can use the whoami command to confirm. For example, after switching to the root account, I enter the following command.

whoami


Output:

root

References


Read More

Tags:

Leave a ReplyCancel reply

Click to Copy
Exit mobile version