Changing Identity
The su command (Switch User) allows you to switch user accounts within the current terminal session. Unlike sudo, which runs a single command as root, su changes your entire shell session.
Switching to a Normal User
If you are root, you can switch to any other user without needing a password:
bash $ su jdoe
Switching to the Root User
To become the root user, use su without a username argument. This requires the root user's password.
bash $ su Password:
You are now the root user (# prompt)
The Recommended Switch (su -)
Using the hyphen (-) option performs a full login, meaning it loads the target user's environment variables, shell settings, and changes the working directory to their home directory. This is essential for administrative work.
bash $ su - jdoe
Full login as jdoe
To exit the switched session and return to your original user, type exit.