sudo
Execute a command as another user, typically root, with privilege elevation.
Synopsis
sudo [OPTION]... COMMAND
Examples
sudo apt update
sudo -u www-data whoami
sudo -i
sudo -l
sudo -E ./script.sh
Common options
| Flag | Description |
|---|---|
| -u | Run as specified user |
| -i | Login shell (simulate initial login) |
| -s | Run shell |
| -l | List allowed commands |
| -k | Invalidate cached credentials |
| -E | Preserve environment variables |
About sudo
The `sudo` command execute a command as another user, typically root, with privilege elevation. User management commands handle creation, modification, and deletion of user accounts and groups.
Multi-user access control is a core feature of Linux. These commands are essential for system administrators managing servers, enforcing security policies, and provisioning access for teams.
The command accepts 6 commonly used flags shown above, though the full set of options is available in the man page (`man sudo`). The 5 examples on this page cover typical real-world usage patterns that you can copy and adapt for your own workflows.
Related commands
More User Management Commands
Other commands in the User Management category