In Linux security, privileges determine what actions a user or process can perform. Privilege escalation is the act of gaining higher access rights than those initially granted — a critical stage in penetration testing, red team operations, and unfortunately, real-world attacks.
For new cybersecurity learners, it's essential to first understand how privileges work before diving into escalation techniques. Without this foundation, privilege escalation may feel like magic rather than a logical exploitation process.
Understanding Linux Privileges
In Linux, privileges are permissions assigned to users and groups to control:
Access to files (read, write, execute)
Execution of system commands
Modifying configurations
Controlling processes
Network access
Key privilege concepts:
Root User (UID 0): Full control over the system. Can bypass all permission checks.
Normal Users: Restricted to their own files and certain commands.
Groups: Collections of users sharing common permissions.
Capabilities: Fine-grained privileges for processes (e.g., CAP_NET_ADMIN).
Example: Checking Current Privileges
whoami # Shows current usernameid # Shows UID, GID, and groupsgroups # Lists groups you belong tosudo -l # Shows commands you can run as root
What is Privilege Escalation?
Privilege escalation is the second phase of most attacks after initial access.
The goal: move from a limited account to root to gain full control, hide activities, and maintain persistence.
Two main categories:
Vertical Escalation: From a lower privilege to a higher privilege (e.g., user → root).
Horizontal Escalation: Gaining access to another account with similar privileges.
Common Privilege Escalation Vectors
1. Exploiting Sudo Misconfigurations
If sudo is configured incorrectly, you may run commands as root without a password.
sudo -l
Example vulnerable configuration:
(ALL) NOPASSWD: /usr/bin/vim
Exploit:
sudo vim -c ':!bash'
Result: Root shell.
2. Exploiting SUID/SGID Binaries
SUID binaries run with the privileges of the file owner.
Find them:
find / -perm -4000 -type f 2>/dev/null
Example:
# If /usr/bin/find has SUID bit set:./find . -exec /bin/sh \; -quit
3. Weak File Permissions
Misconfigured permissions on /etc/passwd or /etc/shadow can be fatal.
ls -l /etc/passwd /etc/shadow
If writable:
openssl passwd newpassword# Replace the root hash in /etc/passwdsu root
Always check sudo -l immediately after getting a shell.
Look for writable directories in /etc/, /var/, and /opt/.
Monitor kernel versions and exploit DBs regularly.
In CTFs, SUID + writable scripts are the most common vector.
Maintain OPSEC — hide artifacts and clean up after testing.
Summary
Privilege escalation in Linux is a critical skill for red teamers and penetration testers. By understanding how privileges work, and systematically checking for misconfigurations, exploitable binaries, and outdated kernels, attackers can gain root access efficiently.
For defenders, this knowledge highlights why least privilege principles and proper hardening are essential.