🖥️Field Reference

Linux for Hackers

A field reference for offensive security & red team operators — filesystem hierarchy, permissions, text processing, networking, SSH tradecraft, privilege escalation checklists, and the command cheat sheet every pentester relies on daily. Companion documentation for the video "Complete Linux for Hackers in 30 Minutes."

💻Filesystem 💻Permissions 💻grep/sed/awk 💻Networking 💻SSH 💻Bash 💻PrivEsc
Back to Home
👤
About This Reference

Author: Aravinda A Kumar — CRTO · OSCP+ · CEH v12 Master

Focus: Active Directory · Web/API Pentesting · Adversary Emulation

Level: Beginner → Intermediate  |  Format: Command reference + enumeration checklists

Caution: This reference is for authorized security testing, CTFs, HackTheBox/lab environments, and systems you own or are explicitly contracted to assess. Always operate within scope and the law.
▶️
Video Walkthrough Reference

This reference accompanies the full "Complete Linux for Hackers in 30 Minutes" series, split across two parts:

▶️Complete Linux for Hackers — Part 1 ▶️Complete Linux for Hackers — Part 2
Table of Contents

🛡️What This Reference Covers

01
Foundations

Filesystem, users, permissions, and the shell.

02
Tradecraft

Text processing, networking, and SSH pivoting.

03
Enumeration

Recon toolkit and the privilege escalation checklist.

04
Reference

The ultimate cheat sheet and lab-building resources.

1. Why Linux Matters for Hackers

💻
The Baseline, Not an Option

Linux underpins the infrastructure hackers actually attack and the infrastructure they attack from. Most internet-facing servers, cloud instances, containers, IoT devices, and every major pentest distribution (Kali, Parrot OS, BlackArch) run on Linux. Fluency here isn't optional — it's the baseline.

  • Attack surface: the majority of servers, routers, and cloud workloads run Linux.
  • Tooling: nmap, Metasploit, Burp Suite, John the Ripper, Impacket — all live comfortably in a Linux shell.
  • Transparency: open-source means you can read the source of the exact daemon you're attacking.
  • Automation: Bash and Python scripting turn manual recon into repeatable, scalable workflows.
Tip: if you only remember one thing from this section — the terminal is not an interface you tolerate, it's the fastest tool you own. Every minute spent getting fluent with it pays back tenfold in an engagement.

📁2. The Filesystem Hierarchy

📂
Where to Look for What

Linux organizes everything under a single root /. Knowing what lives where tells you instantly where to look for credentials, configs, logs, and privilege escalation vectors.

PathWhat it holds
/etcSystem-wide configuration files — passwd, shadow, crontab, service configs. Prime recon target.
/homeUser home directories — often contain SSH keys, shell history, and stray credentials.
/rootThe root user's home directory. Readable only by root — getting here usually means you've won.
/var/logSystem and application logs. Essential for post-exploitation timeline building.
/tmp, /var/tmpWorld-writable scratch space — common staging ground for payloads and exploit compilation.
/procA virtual filesystem exposing live kernel and process information in real time.
/usr/bin, /binExecutable binaries available to all users.
/optThird-party or manually installed software — frequently misconfigured.
/devDevice files representing hardware and virtual devices.
Tip: a quick find / -writable -type d 2>/dev/null early in an engagement tells you exactly where you're allowed to drop files — invaluable during privesc.

🔒3. Users, Groups & Permissions

🔑
The First Wall

Linux permissions are the first wall between a foothold and full compromise. Every file has an owner, a group, and a permission triad (read/write/execute) for owner, group, and others.

$ ls -l /etc/shadow
-rw-r----- 1 root shadow 1520 Jul 24 09:14 /etc/shadow

$ id
uid=1000(alex) gid=1000(alex) groups=1000(alex),27(sudo),999(docker)

Reading permission strings: rwxr-xr-- breaks down as: owner has read/write/execute, group has read/execute, others have read-only. Numerically this is 754 (4=read, 2=write, 1=execute, summed per triad).

👤
Key Identity Files
PathWhat it does
/etc/passwdUser account list — readable by everyone. Reveals valid usernames and shells.
/etc/shadowHashed passwords — root-only. A prime privesc/exfil target if readable.
/etc/groupGroup memberships. Membership in docker, lxd, or disk groups can enable privesc.
/etc/sudoersDefines who can run what as root via sudo. Check with sudo -l first.
Tip: being in the docker or lxd group without root is functionally equivalent to root — both let you mount the host filesystem into a container you control. Always check group membership.

🖥️4. The Shell: Navigation & File Operations

Core Commands
CommandWhat it does
pwdPrint current working directory.
ls -laList all files, including hidden ones, with permissions and ownership.
cd -Jump back to the previous directory.
cp -r src dstCopy directories recursively.
mv old newMove or rename a file.
rm -rf dir/Recursively force-delete a directory. Use with extreme care.
chmod 755 fileSet permissions numerically (owner rwx, group/others rx).
chown user:group fileChange file ownership.
file <name>Identify file type by magic bytes, not extension.
stat fileShow detailed metadata: size, timestamps, inode, permissions.
ln -s target linkCreate a symbolic link.
history | grep sshSearch command history — often reveals credentials or prior recon.
Tip: tab completion and Ctrl+R (reverse search through history) are the two habits that separate someone fluent in the shell from someone fighting it.

🔍5. Text Processing: grep, sed, awk, find

Almost every enumeration task boils down to filtering text. These four tools handle nearly all of it.

🔎
grep — Pattern Search
grep -i 'password' config.php          # case-insensitive match
grep -rn 'API_KEY' /var/www/           # recursive, show line numbers
grep -E '[0-9]{1,3}(\.[0-9]{1,3}){3}' file   # extended regex, e.g. IPs
🔍
find — Locate Files by Attribute
find / -perm -4000 -type f 2>/dev/null   # SUID binaries — classic privesc hunt
find / -writable -type f 2>/dev/null     # world-writable files
find / -name '*.conf' -mtime -7          # config files modified in last 7 days
✏️
sed — Stream Editing
sed 's/foo/bar/g' file.txt   # replace all 'foo' with 'bar'
sed -n '10,20p' file.txt     # print lines 10-20
📊
awk — Field-Based Text Processing
awk -F: '{print $1}' /etc/passwd          # print first field (usernames)
awk '$3 > 1000 {print $1}' /etc/passwd    # users with UID over 1000

⚙️6. Process & Service Management

📊
Commands
CommandWhat it does
ps auxList all running processes with owner, CPU, and memory usage.
ps -ef --forestShow the process tree — useful for spotting parent/child exploitation chains.
top / htopLive view of resource usage per process.
kill -9 <pid>Force-terminate a process.
systemctl status <svc>Check a systemd service's state.
systemctl list-units --type=serviceEnumerate all active services — attack surface mapping.
journalctl -u <svc> -fFollow live logs for a specific systemd service.
crontab -lList scheduled jobs for the current user — common persistence & privesc vector.
cat /etc/crontabCheck system-wide scheduled tasks.
Tip: cron jobs that call scripts in writable locations, or that run as root without an absolute path, are one of the most reliable privilege escalation vectors on misconfigured boxes.

📦7. Package Management

📦
Commands
CommandWhat it does
apt update && apt install <pkg>Debian/Ubuntu/Kali — refresh index and install a package.
apt list --installedList installed packages — useful for spotting outdated/vulnerable software.
dnf install <pkg>Fedora/RHEL-based systems.
pacman -S <pkg>Arch/BlackArch package installation.
dpkg -l | grep <name>Query installed Debian packages directly.
snap listList installed snap packages — another enumeration surface.

🌐8. Networking Fundamentals

🔌
Commands
CommandWhat it does
ip aShow all network interfaces and assigned addresses.
ip routeDisplay the routing table.
ss -tulnpShow listening TCP/UDP ports and owning processes (modern replacement for netstat).
curl -I https://targetFetch HTTP headers only — quick fingerprinting.
dig target.com ANYDNS enumeration — records, mail servers, etc.
nc -lvnp 4444Netcat listener — commonly used to catch reverse shells in a lab.
nc -zv target 1-1000Basic TCP port sweep with netcat.
tcpdump -i eth0 -w cap.pcapCapture live traffic on an interface to a pcap file.
iptables -L -n -vList current firewall rules.
Tip: on any assessment, capture the output of ip a, ss -tulnp, and iptables -L early — it anchors your understanding of what the box can reach and what's listening on it.

🔒9. SSH & Remote Access Tradecraft

🔑
Commands
CommandWhat it does
ssh user@hostBasic interactive SSH connection.
ssh -i key.pem user@hostAuthenticate with a specific private key.
ssh -L 8080:localhost:80 user@hostLocal port forward — tunnel a remote service to your machine.
ssh -D 9050 user@hostDynamic SOCKS proxy — pivot traffic through the target.
scp file user@host:/pathCopy a file to a remote host over SSH.
ssh-keygen -t ed25519Generate a modern SSH keypair.
ssh-copy-id user@hostPush your public key to a remote host's authorized_keys.
Tip: SSH tunneling (-L / -R / -D) is the single most useful pivoting skill in this document. If you only master one networking trick, master dynamic port forwarding for pivoting through a foothold.

📄10. Bash Scripting Essentials

Scripting turns one-off commands into repeatable enumeration and automation. A few patterns cover 80% of what you'll write in the field.

🖥️
Simple Host Sweep
#!/bin/bash
# Simple host sweep for live IPs on a /24
for i in $(seq 1 254); do
  ip="192.168.1.$i"
  ping -c1 -W1 "$ip" &>/dev/null && echo "$ip is up"
done
🔄
Variables, Conditionals, Loops
name="world"
if [ -f /etc/passwd ]; then echo "file exists"; fi
while read -r line; do echo "$line"; done < list.txt
for f in *.txt; do echo "$f"; done
Tip: always quote your variables ("$var" not $var) and set set -euo pipefail at the top of serious scripts — it saves you from silent failures during automated recon.

🔎11. Recon & Enumeration Toolkit

🛡️
Tools

A curated set of tools that cover the vast majority of external and internal recon during an authorized engagement or CTF.

CommandWhat it does
nmap -sC -sV -oA scan targetDefault scripts + version detection, output in all formats.
nmap -p- --min-rate=5000 targetFull TCP port sweep, fast.
gobuster dir -u url -w wordlistDirectory/file brute-forcing on a web target.
nikto -h targetAutomated web server vulnerability scanner.
whatweb targetFingerprint web technologies in use.
enum4linux -a targetSMB/NetBIOS enumeration against Windows/Samba hosts.
smbclient -L //target/List available SMB shares.
crackmapexec smb target -u '' -p ''Sweep credentials/shares across a network via SMB.
hydra -l user -P wordlist ssh://targetOnline credential brute-forcing (lab/authorized use only).
searchsploit <keyword>Offline search of the Exploit-DB database for known CVEs.
Caution: every tool above is built for authorized testing, HTB/CTF labs, or systems you own. Running brute-force or exploitation tooling against systems without explicit authorization is illegal in most jurisdictions.

12. Linux Privilege Escalation Checklist

Structured Enumeration Pass

Roughly in the order most operators run it once they land a low-privilege shell in a lab or authorized engagement.

  • Who am I / what can I run: id, sudo -l
  • Kernel & OS version: uname -a, cat /etc/os-release — check against known kernel exploits
  • SUID/SGID binaries: find / -perm -4000 -o -perm -2000 2>/dev/null — cross-reference against GTFOBins
  • Writable /etc/passwd or /etc/shadow: ls -la /etc/passwd /etc/shadow
  • Cron jobs: cat /etc/crontab, check scripts they call for writable paths
  • Capabilities: getcap -r / 2>/dev/null — binaries with elevated capabilities
  • Sensitive files: SSH keys in home directories, .bash_history, config files with embedded credentials
  • Kernel/container escape indicators: Docker/LXD group membership, exposed Docker socket
  • Automated sweep: run LinPEAS or linux-smart-enumeration in the lab to catch what manual checks miss
Tip: automated enumeration scripts (LinPEAS, LSE) are fast, but they generate noise. Understanding each check manually first is what lets you interpret the automated output correctly instead of drowning in it — and it's what will actually show up in an interview or OSCP exam.

📋13. Logging, Artifact Awareness & Reporting Hygiene

📜
Commands

Understanding what a system logs is essential both for blue-team detection engineering and for writing an accurate, defensible pentest report.

Path / CommandWhat it does
/var/log/auth.log (Debian)Authentication attempts, sudo usage, SSH logins.
/var/log/secure (RHEL)Equivalent auth log on Red Hat-based systems.
/var/log/syslogGeneral system activity log.
last / lastbShow successful and failed login history.
~/.bash_historyCommand history — a goldmine and a liability for defenders and attackers alike.
auditd / ausearchDetailed kernel-level audit logging where configured.
Tip: as a professional, document everything you touch during an authorized engagement — timestamps, commands, and target scope — for the final report. Good notes are what separate a credible pentest deliverable from a screenshot dump.

14. The Ultimate Command Cheat Sheet

CommandWhat it does
whoami; hostname; uname -aQuick environment fingerprint on landing a shell.
history -cClear shell history (lab hygiene / cleanup awareness).
python3 -m http.server 8000Spin up a quick HTTP server to transfer files/tools.
wget http://host/file -O outDownload a file over HTTP.
base64 -w0 fileBase64-encode a file for easy copy/paste transfer.
tar czvf archive.tar.gz dir/Compress a directory.
md5sum file / sha256sum fileGenerate a hash for file integrity verification.
df -hDisk usage per mounted filesystem.
du -sh * | sort -rhFind the largest files/directories in the current path.
watch -n1 'command'Re-run a command every second — handy for monitoring.
xargs -I{} cmd {}Pipe a list of items into repeated command execution.
chmod +x script.shMake a script executable.

🏠15. Building Your Home Lab

🖥️
A Simple, Legal Setup

Everything in this document is meant to be practiced against systems you control.

  • Attacker box: Kali Linux or Parrot OS in a VM (VirtualBox / VMware / UTM).
  • Vulnerable targets: Metasploitable2/3, DVWA, OWASP Juice Shop, or downloadable VulnHub images.
  • Guided practice: HackTheBox and TryHackMe for structured, legal target environments.
  • Isolated networking: keep the lab on a host-only or NAT network, never bridged to your real LAN.
  • Snapshot everything: take VM snapshots before risky changes so you can roll back instantly.

📚16. Further Resources

🔗
Keep Building
  • GTFOBins (gtfobins.github.io) — SUID/sudo binary abuse reference for privesc.
  • HackTricks (book.hacktricks.xyz) — deep enumeration and exploitation methodology wiki.
  • Explainshell (explainshell.com) — paste any shell command to see it broken down flag by flag.
  • OverTheWire: Bandit — a free wargame that teaches core Linux command-line skills interactively.
  • Linux Journey (linuxjourney.com) — structured beginner-to-intermediate Linux fundamentals.
Back to Home