Progress: 0/62 (0%)

🔄 Switching Users (su, sudo)

Switching Users

Imagine you're an employee in the office. Sometimes you need to act as another employee or temporarily use manager privileges. In Linux, this is done with su and sudo.

3a. su (Switch User)

su = "become someone else temporarily."

su john

You'll need John's password. After this, your terminal session is acting as John.

exit

To go back to your own account, type:

Analogy: You borrowed John's ID card to access his office desk and resources. Once done, you return to your own ID.

su

To switch directly to root (the super manager of the office) without specifying a username:

You'll need the root password. Once logged in as root, you can do anything in the system.

3b. sudo

sudo = "do this command as a manager without logging in as them**."

sudo apt update

You stay logged in as yourself but temporarily get manager-level privileges for that one command.

You'll need to enter your own password, not root's.

Analogy: You're still yourself, but the system temporarily hands you a manager key to do one task, then it takes it back.

Useful for security: You don't need to log in as root all the time, reducing risk of mistakes.

Real-life analogy

✅ Key takeaway:
su = fully switch to another user (requires their password)
sudo = execute single commands as root (requires your password)