What Is sudo?

Linux tutorials often show commands like sudo apt install ○○. That sudo at the front is a magic spell meaning "run this with administrator privileges." It's incredibly useful — but if used carelessly, it can break your entire system. Understanding how it works and how to use it safely is essential.

What exactly is sudo?

sudo stands for "Switch User and DO" or "SuperUser DO." It's the command that lets you run another user's commands — usually the administrator's. Linux has a super-powerful admin account called root that has permission to change anything on the system. The standard practice is to stay as a normal user and only borrow root privileges temporarily with sudo when you truly need them.

Windows and Mac have a similar concept: when you install new software, a prompt appears asking "Do you want to allow this app to make changes?" sudo is the Linux equivalent — you just type it instead of clicking a button.

How sudo works

Same command — two different outcomes Whether you include sudo determines "Permission denied" or success ❌ Without sudo: fails student@ubuntu:~$ apt install python3 E: Could not open lock file /var/lib/dpkg/lock-frontend - Permission denied ↑ Writing to system area requires more privileges — error ✅ With sudo: succeeds student@ubuntu:~$ sudo apt install python3 [sudo] password for student: ↑ Password prompt (only once — valid for 15 minutes) Reading package lists... Done python3 successfully installed
Fig 1: sudo "borrows the admin key" temporarily. One password entry unlocks 15 minutes of access.

When you run a command with sudo, it first asks for your password. Once authenticated, you can run additional sudo commands for a few minutes (15 by default) without re-entering your password. Closing the terminal resets the timer.

When do you need sudo?

Commands that need sudo vs. commands that don't Rule of thumb: inside your home folder = no sudo needed / affecting the whole system = sudo needed ✅ No sudo needed Operations inside your home directory ls / cd / pwd List files, navigate, show current path cat / less Read file contents (if you have permission) touch / mkdir Create files/folders in your own directory git / python / node Run programs (after installation) grep / find / wc Search and count ⚠ sudo needed Changes that affect the whole system sudo apt install / update Package management (adding to system) sudo systemctl start / stop Start/stop system services sudo nano /etc/hosts Edit config files under /etc/ sudo useradd / userdel Add or remove user accounts sudo chmod / chown Change permissions on other users' files
Fig 2: Left — everyday commands (no sudo). Right — system-wide changes (sudo needed). Avoid using sudo out of habit.

sudo is only needed for "operations that affect the whole system." You don't need it — and shouldn't use it — for working inside your own home folder (/home/username/). Using sudo to tidy up your own files is like showing a police badge just to organize your personal notebook.

Recommended usage

Installing new software is the most common reason to use sudo. Example: sudo apt install python3 adds Python. The command means "tell apt (Ubuntu's package manager) to install python3." After installation, you run python3 without sudo.

Until you're comfortable, always read through commands you copy from the internet before running them with sudo. A command run with sudo cannot be undone.

For safe practice, start in WSL or a virtual machine where you can easily reset if something goes wrong. Before running any command, check its meaning with man commandname or commandname --help — especially for commands like rm, chmod, chown, and dd, which can make major changes to files or permissions.

Before reaching for sudo, ask yourself: "Is this just my own folder, or does it affect the whole system?" If it's only your files, sudo is not needed. Using sudo unnecessarily can make files root-owned, which means you won't be able to save them later as a regular user.

Traps to watch out for

Things you must never do with sudo
  • Commands like sudo rm -rf / erase the entire OS. Don't just avoid running them — don't even paste them into your terminal.
  • Never run a command you found online that you don't understand with sudo. It could be a trap set by an attacker.
  • Don't habitually prefix everything with sudo. Files will end up root-owned, making them a pain to manage later.

How will this help you in the future?

The idea behind sudo maps directly onto "the principle of least privilege" — a fundamental concept in security design. Run with weak permissions normally; borrow strong permissions only when necessary. This thinking is used everywhere in IT: AWS IAM policies, web admin panels, and corporate system design. Learning this mindset as a teen makes you someone who doesn't do dangerous things — a quality that earns trust in professional environments.

In server operations, it also matters that every use of administrator privileges is logged. sudo is not a convenient shortcut; it's a system that records elevated activity. Grasping this early will help you not just with Linux, but whenever you handle shared systems at school or work.

Start today

3 steps to get started
  1. Run sudo apt update on Ubuntu and experience the password prompt.
  2. Install a fun tool with sudo apt install cowsay and try cowsay hello.
  3. Try opening the /etc/hosts file with and without sudo to feel the difference in permissions.

Summary

sudo is the command that temporarily grants administrator access and should only be used for operations that affect the whole system. The safe practice is to work as a regular user and invoke sudo only when truly needed. Follow two rules: don't run commands you don't understand with sudo, and don't attach sudo out of habit. Stick to those, and you'll learn Linux safely.

Check When do you use sudo?