su command
LINUX-Frequently used commands
su command Switch user. |
Syntax |
su [-] [user-name] |
The su command is used to switch between users. To use the su command, specify the user name you wish to switch to as an argument. If you do not specify a user name, you will be switched to the superuser.. |
Frequently used options |
- Change to a specified user environment. |
Example: Switch user. |
$ whoami ← Show current users koro $ su korokoro ← Change the user to korokoro with the su command $ whoami ← Show current users korokoro $ exit ← exit to return to the original user $ whoami ← Show current users koro |
Example: Switch to superuser root and then back to general user. |
$ whoami ← Show current users koro $ su - ← Change to root with the su command passwd: Enter root password # whoami ←Show current users root # su - koro ← Change to the general user koro with the su command $ whoami ← Show current users koro |