Linux Privilege Escalation Cheat Sheet: Enumeration & Hardening

Essential Linux local enumeration commands for auditing sudoers rules, SUID binaries, file capabilities, cron jobs, and exposed credentials.

Take This Page With You

Every command on this page is ready to run as written.

Command Reference

1. System, Kernel & OS Release Triage

Check kernel version, architecture, and distribution release level.

uname -a && cat /etc/os-release && lscpu

2. Check Sudo Privileges for Current User

List commands the current user may run as root or another user via sudo.

sudo -l

3. Find SUID & SGID Binaries

Locate binaries executing with owner (root) permissions and cross-check against GTFOBins.

find / -perm -4000 -type f 2>/dev/null

4. Enumerate Linux File Capabilities

Spot binaries granted powerful capabilities such as cap_setuid+ep or cap_dac_read_search.

getcap -r / 2>/dev/null

5. Inspect System & User Cron Jobs

Check scheduled tasks for world-writable scripts or wildcard injection.

cat /etc/crontab && ls -la /etc/cron* /var/spool/cron/crontabs 2>/dev/null

6. Local Loopback Services (127.0.0.1)

Find internal databases, admin panels, or debug ports bound only to localhost.

ss -tulpn

7. World-Writable Directories & Config Files

Audit /etc and service paths for misconfigured write permissions.

find /etc -writable -type f 2>/dev/null

8. Search for Leaked Environment & History Secrets

Check environment variables, shell history, and app config files for cleartext keys.

env && grep -rnE "password|secret|apikey|token" /var/www /opt 2>/dev/null

Frequently Asked Questions

Why are Linux file capabilities often missed during manual audits?

Unlike traditional SUID bits that show an "s" in ls -l output, POSIX capabilities (such as cap_setuid+ep on python3 or tar) are stored in extended file attributes and only appear when queried with getcap -r /.

How do defenders harden servers against sudo and SUID escalation?

Avoid NOPASSWD wildcard rules in /etc/sudoers, mount /tmp and /home with nosuid,noexec, and remove unnecessary SUID bits from standard utilities.


Related Guides, Tools & Cheat Sheets