Skip to main content
Kill -9 Club
Sign in

sudo

AccountsPackage: sudo

Runs one command with another account's rights, root by default, and logs who asked for it. It is not "becoming root": each command is allowed or refused by /etc/sudoers, and that file is where what an account can really do is read.

What its options do in the lessons

From the same glossary the lessons render under their commands, so the two cannot disagree.

sudo -i
Opens a login shell for the target user — root unless -u names another: profiles read, environment rebuilt, starting in their home directory. Followed by a command, it runs inside that environment.
sudo -u
Runs the command as that user rather than root. sudo -u postgres psql opens psql with the identity PostgreSQL expects.
sudo -l
Lists what you are allowed to do with sudo, without running anything.
sudo -E
Keeps your environment variables. Avoid by default: clearing them is exactly how sudo stops a caller-chosen variable changing what root does.
sudo -H
Sets HOME to the target user's directory, so a tool does not write its configuration into yours.
sudo -e
Edits a file without running the editor as root: sudoedit copies it to a temporary file, you edit it as yourself, and it is written back into place. Your editor — with its plugins, and its shell-escape commands — never runs with administrative rights.

Lessons that teach it