3. User Types and Login
π₯ User Categories
| π΄ Administrator (Privileged User) |
π Regular User (Unprivileged User) |
|
**Username:** `root`
β
Full system access
β
Can modify any file or setting
β
Can install software system-wide
π΄ Prompt ends with `#`
|
**Username:** varies (`alice`, `bob`, etc.)
β οΈ Limited system access
β
Can modify files in home directory
β Cannot change system settings
π Prompt ends with `$`
|
π Switching Users
π Quick Reference
| Command |
Description |
Password Required |
su - <username> |
Switch to another user |
Userβs password |
su - |
Switch to root |
Root password |
sudo su |
Switch to root |
Your password |
sudo <command> |
Run single command as root |
Your password |
sudo -i |
Interactive root shell (root environment) |
Your password |
sudo -s |
Interactive root shell (user environment) |
Your password |
π» Command Examples
# Switch to another regular user (- can be omitted)
su - alice
# Switch to root account (prompts for Root password)
su -
# Switch to root account (prompts for User password)
sudo su
# Run single command as another user (root or administrator in that case)
sudo apt update
# Run command as specific user
sudo -u postgres psql
# Get interactive root shell
# Switches to Root environment (home)
sudo -i
# or (Remains in user environment)
sudo -s
π Whoβs Logged In?
# Show all logged in users
who
ββββββββββββββββββββββββββββββββββββ
β alice tty1 2024-02-08 10:30 β
β bob pts/0 2024-02-08 11:15 β
ββββββββββββββββββββββββββββββββββββ
# Show information about current session
who am i
# Show current username
whoami
alice
# Show detailed user activity
w
βββββββββββββββββββββββββββββββββββββββββββββββββββββ
β USER TTY LOGIN@ IDLE WHAT β
β alice pts/0 10:30 0.00s w β
β bob pts/1 11:15 5:30 vim document.txt β
βββββββββββββββββββββββββββββββββββββββββββββββββββββ
Navigation
Next: β Linux File System Structure
Previous: β The Shell Your Command Interface
Lesson Home: β Lesson 2: The Shell
Course Home: β Introduction to Linux