UnixDroid

Permissions · Linux command

sudo command in Linux

What does sudo do?

sudo runs a single command with administrator (root) rights, after checking that your user is allowed to in the sudoers rules.

sudo [options] command

Most useful options

OptionWhat it does
-llist what you may run with sudo
-u userrun as another user
-iopen a root login shell
-kforget the cached password

sudo examples

$ sudo apt update Try it ›

update package lists

$ sudo -l Try it ›

see your sudo rights

$ sudo -u www-data whoami Try it ›

run as the web user

In security work

Give users sudo rights only for what they really need, and review the sudoers rules regularly.

Questions about sudo

What is the difference between sudo and su?

sudo runs one command as root with YOUR password; su switches to another user with THEIR password.