Beginner Package: sudo

sudo

Run a single command with another user's (usually root's) privileges.

Syntax

sudo [options] command

Description

sudo temporarily elevates privileges for one command at a time, based on rules in /etc/sudoers, and is the standard alternative to logging in directly as root โ€” every action is also logged for accountability.

Examples

sudo apt update
Run a single command as root
sudo -u www-data whoami
Run a command as a specific user other than root
sudo -l
List the commands your account is permitted to run with sudo
sudo -i
Start an interactive root shell

Applies to

Ubuntu Debian Linux Mint RHEL CentOS / Rocky / AlmaLinux Fedora Arch Linux openSUSE Alpine Linux