# Root User and sudo

> Who the root user is and why it can change anything. How sudo runs one command as root, and why you should not log in as root at all.

**Course:** [Linux Command Line](https://learn.benibix.com/learn/infrastructure-linux)  
**Time:** 10 min

**After this lesson you can:**

- Say what the root user may do
- Run one command with sudo
- Explain why daily work is done as a normal user

## Why you stop using root

The root user is the boss account on Linux. Its user number is 0, and it can read, change or delete any file on the machine. Normal users cannot touch system files. sudo lets a normal user run one command as root, after typing their own password. Day-to-day work is done as a normal user, with sudo only when needed.

Root is the way the system protects itself. A normal user can only harm their own files. A mistake made as root can wipe the whole machine. So can a bad program, if root starts it.

sudo goes in front of a command, such as sudo apt update. It asks for your own password, not root's. Only users on an allowed list may use it. Every command run this way is written to a log, so there is a record of who did what.

After you type your password, sudo trusts you for a few minutes, 15 by default on Ubuntu. Commands in that window do not ask again. Close the terminal, or wait, and it asks once more.

Many servers start with a root login only. The first job is to make a normal user, give it the right to use sudo, and log in as that user from then on. Logging in as root directly is then often switched off.

sudo also makes you slow down. Typing it is a small pause that says this command can break things. People who work as root all day lose that pause and make bigger mistakes.

A common mistake is to put sudo in front of a command that fails, just to make it work. When a command fails with permission denied in your own folder, the file is likely someone else's. Fix the owner. Do not run all your work as root from then on.

```console
$ whoami
jack
$ sudo whoami
[sudo] password for jack:
root
```
The same command, with and without sudo. sudo asks for Jack's own password, then runs it as root.

![On the left, Jack, a normal user, types a command with sudo in front. A checkpoint asks for Jack's own password and checks that he is on the allowed list. The command then runs as root, user 0, on the right, and a line is written to the log below.](https://learn.benibix.com/diagrams/inf3-sudo.svg)

### Example: A new server's first five minutes

Lucy's new server lets her in as root. She makes a user called lucy and adds it to the group allowed to use sudo.

She logs out and back in as lucy, and runs sudo whoami to check it says root. From then on, only commands that need it carry sudo.

**Words in this lesson:** [Root User](https://learn.benibix.com/term/infrastructure/root-user), [sudo](https://learn.benibix.com/term/infrastructure/sudo)

**Question:** Whose password does sudo ask for?

**Answer:** Your own password. sudo asks for your own password, then checks that you are on the list of users allowed to act as root. Root's password is never shared.

---

Source: https://learn.benibix.com/learn/infrastructure-linux/root-user-and-sudo
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-19
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
