Definition:
If you want temporary access to another account, you use the su command.
For example, if you are logged in as user abha and want to switch to user prabha, you type:
su prabha
In simple words, it helps you jump from one account to another for a short time, so that you can work as that user.
Syntax:
su [option] [username]
Options:
-l→ Full login mode. Switches to the target user along with their environment.su - prabha-c→ Run a single command as the target user, then return to your original user.su -c "ls /home/prabha" prabha--help→ Shows help information about thesucommand.
Example:
Current user: abha
User you want to switch to: prabha
Command:
su prabha
Output / Explanation:
- Now you are logged in as
prabha. - To return to your original user, simply type
exitor press Ctrl + D. - Now you are back as
abha.
