man.lsPlain-English help for Unix commands

sudo Run a command as another user

Runs one command with the rights of another user, most often the super user (root). You use it for tasks that normal accounts are not allowed to do, such as editing system files or changing file owners. It asks for your own password, not root's.

Synopsis

sudo [-u user] command [arg ...]
sudo -i | -s
sudo -l | -v | -k

Common options

Option or formWhat it does
-u userRun the command as this user instead of root
-iStart a login shell as the target user, with that user's environment and home folder
-sStart a shell as the target user, keeping more of your own environment than -i
-lList what you are allowed to run with sudo. Give a command to check only that one
-vRefresh the password timestamp without running a command
-kForget the cached password, so the next sudo asks again
-EKeep your environment variables when running the command
-eEdit a file as the target user using a temporary copy, rather than running an editor as root

Examples

Run one command as root
sudo ls /var/root
See what sudo lets you do
sudo -l
Run a command as a different user
sudo -u alice whoami
Change the owner of a file
sudo chown alice:staff report.pdf
Edit a protected file safely
sudo -e /etc/hosts
Forget your cached password
sudo -k

Notes

See also

Last reviewed 2026-10-07.