Lesson 3 of 8

Users, Groups & sudo

User and group management is central to Linux security, controlling who can access what resources and run which commands. You will learn how to create and manage users, understand the /etc/passwd and /etc/shadow files, and configure sudo to grant controlled administrative access. Misconfigurations in sudo rules are one of the most common privilege escalation vectors on Linux systems.

Learning Objectives — Deep Dive

Each objective below is broken down into plain English so you know exactly what you are learning, why it matters, and what you will be able to do when you are done. Mark each one complete as you work through the lesson.

0/4
In plain English

This is a hands-on skill — you are learning to actually do something, not just understand it theoretically. The goal is muscle memory: being able to perform this action reliably under pressure, in a real engagement, without having to look it up every time. Practice until it feels automatic.

Why this matters

Almost every professional security tool runs on Linux, and almost every server you will ever test runs Linux. Fluency in the terminal is not optional — it is the foundation that every other skill in this field is built on.

Real-world analogy

Think of it like learning to drive. You do not need to understand how the engine works to drive safely, but knowing the basics helps you diagnose problems and avoid mistakes that could cause accidents. The same principle applies here — foundational knowledge prevents costly errors.

What you will be able to do

Navigate a Linux system confidently from the command line, write basic automation scripts to speed up repetitive tasks, and use the terminal-based security tools that are standard in professional penetration testing.

Beginner tip

Do not try to memorize everything at once. Read through the material once to get the big picture, then go back and work through the lab. The hands-on practice is what makes the concepts stick — passive reading alone will not get you there.

Users, Groups & sudo · Objective 1 of 4

VIDEO
Loading video…
1

Check current user context

Run 'id' to display your current user ID, group ID, and all supplementary groups. Run 'whoami' to confirm your username, and 'hostname' to confirm which machine you are on — essential when pivoting through multiple systems. Run 'uname -a' to get the kernel version, which you will need to search for kernel exploits. Run 'cat /etc/os-release' to identify the exact Linux distribution and version. These four commands should be the first thing you run after gaining access to any new system.

id && whoami && uname -a
2

Read /etc/passwd

Run 'cat /etc/passwd' and look for accounts with UID 0 — any account with UID 0 has root-level privileges regardless of its username. Also look for accounts with unusual home directories (such as /var/www or /opt) which may indicate service accounts with shells that should not have them. Check for accounts with empty password fields (the second field between the first and second colons) — an empty password field means the account has no password and can be logged into without one. Export the usernames for use in brute force attacks: 'cut -d: -f1 /etc/passwd > users.txt'.

cat /etc/passwd | awk -F: '$3==0{print}'
3

Check sudo permissions

Run 'sudo -l' to list all commands the current user is permitted to run with sudo. The output shows which commands can be run as which users — 'ALL=(ALL) NOPASSWD: ALL' means the user can run any command as root without a password, which is a complete privilege escalation. Even restricted sudo entries can be exploitable: 'sudo /usr/bin/find' allows privilege escalation via GTFOBins, and 'sudo /usr/bin/vim' allows shell escape. Always check sudo -l immediately after gaining access to a new account.

sudo -l
4

Look up sudo binaries on GTFOBins

For each binary listed in your 'sudo -l' output, visit gtfobins.github.io and search for that binary name. Click the 'Sudo' filter to see only techniques applicable to sudo-based privilege escalation. GTFOBins provides copy-paste commands for each technique — for example, if sudo allows /usr/bin/find, the GTFOBins entry shows 'sudo find . -exec /bin/sh \; -quit' to spawn a root shell. Bookmark GTFOBins and use it as your first reference whenever you find an unusual sudo permission or SUID binary.

5

Escalate privileges

Using the technique identified from GTFOBins, execute the privilege escalation and verify success by running 'id' — the output should show 'uid=0(root)'. Once you have a root shell, run 'cat /etc/shadow' to confirm you can read the shadow file, which proves full system compromise. In a CTF or penetration test, the next step is to read the root flag file (typically at /root/root.txt) as proof of compromise. Document the exact commands used, the output at each step, and the time of escalation for your report.

sudo find . -exec /bin/sh \; -quit