IntroToLinux

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?

πŸ‘€ User Information Commands

# 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    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Next: β†’ Linux File System Structure
Previous: ← The Shell Your Command Interface
Lesson Home: ↑ Lesson 2: The Shell
Course Home: βŒ‚ Introduction to Linux