sudo

Run a command with admin rights

What it does

sudo runs the command after it as root, the user who can do anything: edit system files, install packages, manage services. It asks for your own password, not root's, and then does not ask again for a while (15 minutes on Ubuntu).

Only users who are allowed to can use sudo: on Ubuntu and Debian, members of the sudo group. Forgot to type sudo? Repeat the last command with sudo !!. sudo -u <user> runs a command as another user instead of root.

Careful. With sudo the system no longer protects you from mistakes: a typo in a path given to rm, chmod or chown can break the server. Reread the command before pressing Enter, and do not add sudo "just in case" where it is not needed.

Syntax

sudo <command>
sudo -u <user> <command>
sudo !!

Examples

Related commands

Practise · All commands