Skip to content
BENIBIX Learn

sudo

Infrastructure⌨️ Linux & the Command LineUsers and Permissions

Also known as sudo Command, Superuser Do, Run as Root

A command that runs one line as the root user. It asks for your password first.

Think of it like

Think of it like asking a grown-up to reach the top shelf for you. You ask, and they check first.

Example

Jack needs to install a program on his server. He types sudo apt install nginx and enters his own password.

Why it matters

You get root power only when you need it. The rest of the time a typo stays small.

Definition

sudo runs one command with the power of the root user. You type sudo before the command. It asks for your own password, not the root password. Only users on an allowed list may use it. Each use is written to a log, so there is a record of who did what.

Example code

console
$ whoami
jack
$ sudo whoami
[sudo] password for jack:
root
The same command, run twice. With sudo in front, it runs as root.
Jack asks with sudo, gives his own password, and one command runs as root.

Common mistake

Putting sudo in front of every command out of habit. Then files end up owned by root, and normal tools cannot touch them.

Key takeaways

  1. 1
    One command. Root power for just that line.
  2. 2
    Your password. Not the root password.
  3. 3
    Logged. There is a record of each use.

Compare

Learn it properly