Command literacy

Commands

170 annotated commands — Linux, Windows, networking connectivity (ping/mtr/traceroute, DNS, curl/httpie, nc/ss/nmap, firewalls, SSH/SCP), plus cloud and containers. Each entry has flags, lab examples, how to read output, and common mistakes. Study here; run only on systems you own.

These are knowledge references, not a live terminal. Prefer in-browser Labs for practice. Never run reconnaissance or exploit tooling against systems you do not own or have written authorization to test.

Linux (61)

ls— Lists directory contents. Long format (-l) is the security analyst’s def…

What it does

Lists directory contents. Long format (-l) is the security analyst’s default: permissions, owner, size, and timestamps tell you who can read secrets and whether a binary looks newly dropped.

Syntax

ls [options] [path]

Important flags / options

  • -lLong format with permissions
  • -aInclude hidden files (dotfiles)
  • -hHuman-readable sizes
  • -tSort by mtime

Example (lab)

ls -lah /etc/ssh

Example output

drwxr-xr-x 2 root root 4.0K Jan 10 .
-rw-r--r-- 1 root root 3.2K Jan 10 sshd_config

How to read it: d = directory; rwxr-xr-x means owner rwx, group/other rx. sshd_config is world-readable — normal for that file, but never for private keys.

Common mistakes

  • Forgetting -a hides .ssh and .env
  • Assuming the listed user owns every process that uses the file
cd— Changes the current working directory for this shell. Scripts and relati…

What it does

Changes the current working directory for this shell. Scripts and relative paths break when you are in the wrong place — always pair with pwd when documenting a lab.

Syntax

cd [dir]

Important flags / options

  • ~Home directory
  • ..Parent directory
  • -Previous directory
  • /Filesystem root

Example (lab)

cd /var/log

Example output

(no output)

How to read it: Silence means success. Confirm with pwd → /var/log before grepping logs.

Common mistakes

  • Paths with spaces need quotes
  • cd into a symlink and losing track of the real path
pwd— Prints the absolute path of the current directory. Relative paths in not…

What it does

Prints the absolute path of the current directory. Relative paths in notes are ambiguous; absolute paths make lab write-ups reproducible.

Syntax

pwd

Important flags / options

  • -PPhysical path (resolve symlinks)

Example (lab)

pwd

Example output

/var/log

How to read it: You are in /var/log — greps without a path will look here.

Common mistakes

  • Mixing ~ expansion with scripts that do not expand it
grep— Searches line-oriented text for a pattern. First tool for log triage: fa…

What it does

Searches line-oriented text for a pattern. First tool for log triage: failed logins, error strings, IOCs. Prefer ripgrep (rg) when installed for speed; grep is everywhere.

Syntax

grep [options] PATTERN [file]

Important flags / options

  • -iCase-insensitive
  • -rRecursive through directories
  • -cCount matching lines
  • -EExtended regex
  • -nShow line numbers

Example (lab)

grep -c "Failed password" /var/log/auth.log

Example output

37

How to read it: 37 failed SSH password attempts — correlate with source IPs (awk/cut) for brute-force evidence in a lab.

Common mistakes

  • Unquoted patterns with spaces
  • Recursive grep on huge binary trees without --exclude
find— Walks a directory tree and selects files by name, type, size, or mode. S…

What it does

Walks a directory tree and selects files by name, type, size, or mode. Security use: SUID binaries, world-writable dirs, recently modified files under /tmp.

Syntax

find [path] [expression]

Important flags / options

  • -nameMatch filename (shell globs)
  • -type fRegular files only
  • -perm -4000SUID bit set
  • -mtime -1Modified in last day

Example (lab)

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

Example output

/usr/bin/passwd
/usr/bin/sudo

How to read it: These SUID programs escalate to root by design — compare against a known-good list when hunting unknown SUID for privesc.

Common mistakes

  • Forgetting 2>/dev/null floods Permission denied
  • find / without limits on huge disks
chmod— Sets Unix permission bits (read/write/execute for user/group/other). Wro…

What it does

Sets Unix permission bits (read/write/execute for user/group/other). Wrong modes leak keys or break services; 777 is almost never the right fix.

Syntax

chmod MODE file

Important flags / options

  • u/g/o/aWho: user/group/other/all
  • 755rwxr-xr-x (common for dirs/bins)
  • 600rw------- (secrets/keys)
  • +xAdd execute

Example (lab)

chmod 600 ~/.ssh/id_ed25519

Example output

(no output)

How to read it: Private key readable only by you. OpenSSH refuses keys that are group/world-readable.

Common mistakes

  • chmod 777 to "fix" access
  • Recursive chmod -R 777 on /var/www
chown— Changes file owner and optionally group. Web roots often need www-data o…

What it does

Changes file owner and optionally group. Web roots often need www-data ownership; stealing ownership of system files breaks the OS.

Syntax

chown USER[:GROUP] file

Important flags / options

  • -RRecursive
  • user:groupSet both

Example (lab)

sudo chown www-data:www-data /var/www/app

Example output

(no output)

How to read it: The app tree is now owned by the web user — pair with sane chmod, not 777.

Common mistakes

  • chown -R on / or /usr
  • Changing ownership instead of fixing the ACL problem
ps— Snapshot of running processes. Spot unexpected reverse shells, crypto mi…

What it does

Snapshot of running processes. Spot unexpected reverse shells, crypto miners, or leftover lab listeners by name/PID/user.

Syntax

ps [options]

Important flags / options

  • auxBSD style: all users, detail
  • -efSystem V full format
  • --forestProcess tree

Example (lab)

ps aux | grep sshd

Example output

root  812 0.0 0.1 sshd: /usr/sbin/sshd -D

How to read it: PID 812 is the SSH daemon as root — expected. Note the grep line also matching itself.

Common mistakes

  • Trusting process names (easy to spoof)
  • Killing PIDs without confirming the command line
netstat— Legacy view of sockets and routing. Still appears in older docs; on mode…

What it does

Legacy view of sockets and routing. Still appears in older docs; on modern Linux prefer ss. Shows what is listening and who is connected.

Syntax

netstat [options]

Important flags / options

  • -t/-uTCP / UDP
  • -lListening only
  • -nNumeric (no DNS)
  • -pProcess (needs root for others)

Example (lab)

sudo netstat -tlnp

Example output

tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 812/sshd

How to read it: SSH listens on all IPv4 interfaces (0.0.0.0:22). On a lab VM that may be OK; on a cloud box, restrict with firewall/SG.

Common mistakes

  • Assuming netstat exists on minimal containers
  • Ignoring UDP listeners
ss— Modern replacement for netstat — faster and always maintained. Default s…

What it does

Modern replacement for netstat — faster and always maintained. Default skill for “what is listening?” during hardening and IR.

Syntax

ss [options]

Important flags / options

  • -tTCP
  • -uUDP
  • -lListening
  • -nNumeric
  • -pProcess names

Example (lab)

ss -tlnp

Example output

LISTEN 0 128 127.0.0.1:5432 users:(("postgres",pid=900))

How to read it: Postgres bound to localhost only — not reachable from other hosts. Contrast with 0.0.0.0 bindings.

Common mistakes

  • Without sudo, -p may omit process names
  • Misreading [::] vs 0.0.0.0
curl— HTTP/HTTPS (and more) client. Security workhorses: fetch headers, replay…

What it does

HTTP/HTTPS (and more) client. Security workhorses: fetch headers, replay APIs, check redirects, grab robots.txt — on targets you own.

Syntax

curl [options] URL

Important flags / options

  • -IHEAD / headers only
  • -vVerbose (TLS, headers)
  • -XHTTP method
  • -dRequest body
  • -LFollow redirects
  • -HCustom header

Example (lab)

curl -I http://localhost:8000

Example output

HTTP/1.0 200 OK
Server: SimpleHTTP/0.6 Python/3.12

How to read it: 200 OK and a revealing Server banner — useful inventory, also an info leak to fix in production.

Common mistakes

  • Forgetting -L and thinking the app is down
  • -k ignoring TLS errors on real sites
wget— Download files non-interactively. Fine for lab ISOs and wordlists; dange…

What it does

Download files non-interactively. Fine for lab ISOs and wordlists; dangerous when blindly fetching and executing remote scripts.

Syntax

wget [options] URL

Important flags / options

  • -OOutput filename
  • -qQuiet
  • -cContinue partial
  • --spiderCheck existence only

Example (lab)

wget -O page.html http://localhost:8000

Example output

‘page.html’ saved [1024/1024]

How to read it: File landed locally — open it; do not pipe wget to sh.

Common mistakes

  • curl|bash / wget|sh patterns
  • Overwriting files with -O by mistake
head— Shows the first lines of a file.

What it does

Shows the first lines of a file.

Syntax

head [options] file

Important flags / options

  • -nNumber of lines

Example (lab)

head -n 5 /var/log/syslog

Example output

…first 5 lines…

How to read it: Quick peek without opening the whole log.

Common mistakes

  • Assuming logs are small enough to cat entirely
tail— Shows the end of a file; great for live logs.

What it does

Shows the end of a file; great for live logs.

Syntax

tail [options] file

Important flags / options

  • -fFollow
  • -nLines

Example (lab)

tail -f /var/log/auth.log

Example output

…streaming new lines…

How to read it: Watch authentication events live in a lab.

Common mistakes

  • Following huge noisy logs without filters
chmod (sticky)— Sticky bit on directories (e.g. /tmp) restricts delete to owner.

What it does

Sticky bit on directories (e.g. /tmp) restricts delete to owner.

Syntax

chmod +t dir

Example (lab)

ls -ld /tmp

Example output

drwxrwxrwt … /tmp

How to read it: The t means sticky bit is set.

Common mistakes

  • Confusing sticky with SUID
systemctl— Manage systemd services.

What it does

Manage systemd services.

Syntax

systemctl [cmd] [unit]

Important flags / options

  • statusShow state
  • start/stopControl
  • enableStart on boot

Example (lab)

systemctl status ssh

Example output

active (running)

How to read it: Confirms ssh service state on a lab VM.

Common mistakes

  • Disabling critical services on shared hosts
journalctl— Query the systemd journal.

What it does

Query the systemd journal.

Syntax

journalctl [options]

Important flags / options

  • -uUnit
  • -fFollow
  • --sinceTime filter

Example (lab)

journalctl -u ssh -n 20

Example output

…recent ssh logs…

How to read it: Central place for service logs on systemd distros.

Common mistakes

  • Forgetting time filters on busy hosts
whoami— Prints the current effective username.

What it does

Prints the current effective username.

Syntax

whoami

Example (lab)

whoami

Example output

alice

How to read it: Confirms which user you are after sudo/su.

Common mistakes

  • Assuming you are root
id— Shows uid/gid and group memberships.

What it does

Shows uid/gid and group memberships.

Syntax

id [user]

Example (lab)

id

Example output

uid=1000(alice) gid=1000(alice) groups=1000(alice),27(sudo)

How to read it: Group memberships matter for privilege reviews.

Common mistakes

  • Ignoring supplementary groups
auditctl— Linux audit framework control.

What it does

Linux audit framework control.

Syntax

auditctl -l

Important flags / options

  • -wWatch path

Example (lab)

sudo auditctl -l

Example output

LIST_RULES: …

How to read it: Compliance and tamper detection.

Common mistakes

  • Overly broad watches filling disks
getfacl— View POSIX ACLs beyond chmod bits.

What it does

View POSIX ACLs beyond chmod bits.

Syntax

getfacl file

Example (lab)

getfacl /shared/project

Example output

user:alice:rwx …

How to read it: Find excessive ACL grants.

Common mistakes

  • Ignoring default ACLs on directories
setfacl— Modify ACL entries.

What it does

Modify ACL entries.

Syntax

setfacl -m u:user:perms file

Important flags / options

  • -mModify
  • -xRemove

Example (lab)

setfacl -m u:bob:r-- confidential.txt

Example output

(updated ACL)

How to read it: Granular sharing — review for abuse.

Common mistakes

  • Granting rwx to everyone via ACL
umask— Default permission mask for new files.

What it does

Default permission mask for new files.

Syntax

umask

Example (lab)

umask

Example output

0022

How to read it: Explains why new files are 644/755.

Common mistakes

  • Setting umask 000 on shared servers
cat— Concatenates and prints file contents to stdout. Security students use i…

What it does

Concatenates and prints file contents to stdout. Security students use it to read configs, logs, and flags in CTFs — but for large logs prefer less/tail so you do not flood the terminal.

Syntax

cat [file …]

Important flags / options

  • -Read from stdin
  • > fileShell redirect (overwrite)

Example (lab)

cat /etc/os-release

Example output

NAME="Ubuntu"
VERSION="22.04.3 LTS (Jammy Jellyfish)"

How to read it: Shows distribution identity — useful when choosing package managers or vulnerability lookup for that OS.

Common mistakes

  • catting multi‑GB logs
  • Using cat file | grep X instead of grep X file
less— Pager for browsing long text. Search with /, next match n, quit with q. …

What it does

Pager for browsing long text. Search with /, next match n, quit with q. Safer than cat for logs because it does not dump everything at once.

Syntax

less [file]

Important flags / options

  • /patternSearch forward
  • GJump to end
  • qQuit

Example (lab)

less /var/log/syslog

Example output

(interactive view)

How to read it: You scroll and search inside the viewer; nothing is printed until you ask.

Common mistakes

  • Leaving less open while logs rotate
  • Assuming arrow keys work the same in every terminal
cut— Extracts columns from delimited text. Pair with grep/awk for quick log t…

What it does

Extracts columns from delimited text. Pair with grep/awk for quick log triage without a full SIEM.

Syntax

cut -d DELIM -f FIELDS

Important flags / options

  • -dDelimiter (default tab)
  • -fField numbers
  • -f1,3Multiple fields

Example (lab)

echo "alice:x:1000:1000::/home/alice:/bin/bash" | cut -d: -f1,7

Example output

alice:/bin/bash

How to read it: Username and login shell from a passwd-style line — classic recon of local accounts.

Common mistakes

  • Wrong delimiter (space vs colon)
  • 1-based field numbers off-by-one
awk— Programmable text processor. In IR and CTFs, awk pulls fields, counts, a…

What it does

Programmable text processor. In IR and CTFs, awk pulls fields, counts, and filters without writing a full script.

Syntax

awk 'pattern { action }' [file]

Important flags / options

  • -FField separator
  • {print $1}Print first field
  • NR==1First record only

Example (lab)

ss -tln | awk 'NR>1 {print $4}'

Example output

0.0.0.0:22
127.0.0.1:5432

How to read it: Local addresses of listening TCP sockets — quick exposure check.

Common mistakes

  • Forgetting quotes around the program
  • Assuming CSV quoting rules like Excel
sed— Stream editor for find/replace and line edits. Useful for scrubbing secr…

What it does

Stream editor for find/replace and line edits. Useful for scrubbing secrets from demos or normalizing configs — never silently rewrite production without review.

Syntax

sed [options] 'script' [file]

Important flags / options

  • -nQuiet
  • s/a/b/gGlobal substitute
  • -iIn-place edit (dangerous)

Example (lab)

echo 'password=secret' | sed 's/=.*/=REDACTED/'

Example output

password=REDACTED

How to read it: Shows how to sanitize sensitive lines before sharing logs.

Common mistakes

  • sed -i without backup on important files
  • Unescaped special characters in patterns
sort / uniq— Sort lines then collapse duplicates. With -c you get frequency counts — …

What it does

Sort lines then collapse duplicates. With -c you get frequency counts — perfect for top failed logins or top URLs.

Syntax

sort [file] | uniq [-c]

Important flags / options

  • -nNumeric sort
  • -rReverse
  • uniq -cCount duplicates

Example (lab)

cut -d' ' -f1 access.log | sort | uniq -c | sort -nr | head

Example output

1201 203.0.113.10
88 198.51.100.2

How to read it: IP 203.0.113.10 dominates requests — investigate first in a lab incident.

Common mistakes

  • uniq without sort (duplicates must be adjacent)
  • Sorting huge files without enough disk for temp
wc— Word/line/byte counts. Fast way to size logs or count findings before op…

What it does

Word/line/byte counts. Fast way to size logs or count findings before opening them.

Syntax

wc [options] [file]

Important flags / options

  • -lLines
  • -wWords
  • -cBytes

Example (lab)

wc -l /var/log/auth.log

Example output

18402 /var/log/auth.log

How to read it: 18k auth lines — plan filtering before grepping blindly.

Common mistakes

  • Assuming line count equals events (multi-line entries exist)
stat— Shows inode metadata: size, permissions, owner, and atime/mtime/ctime. F…

What it does

Shows inode metadata: size, permissions, owner, and atime/mtime/ctime. Forensics students use this to spot unexpected timestamps.

Syntax

stat file

Important flags / options

  • -c %aOctal mode
  • -c %yModification time

Example (lab)

stat /etc/passwd

Example output

Access: (0644/-rw-r--r--)
Modify: 2024-01-10 08:00:00

How to read it: World-readable passwd is normal; compare Modify time if you suspect tampering.

Common mistakes

  • Trusting atime on systems with relatime/noatime
file— Guesses file type from magic bytes, not the extension. Critical when a '…

What it does

Guesses file type from magic bytes, not the extension. Critical when a 'photo.jpg' is actually an ELF binary or script.

Syntax

file [path]

Important flags / options

  • -bBrief
  • -iMIME type

Example (lab)

file mystery.bin

Example output

mystery.bin: ELF 64-bit LSB executable, x86-64

How to read it: Treat as executable malware lab sample — open only in a sandbox.

Common mistakes

  • Trusting the filename extension alone
strings— Extracts printable ASCII/Unicode from binaries. Quick first look for URL…

What it does

Extracts printable ASCII/Unicode from binaries. Quick first look for URLs, paths, and error messages in malware or unknown binaries (lab only).

Syntax

strings [options] file

Important flags / options

  • -nMin length
  • -aScan whole file

Example (lab)

strings -n 8 sample.exe | head

Example output

http://evil.lab/callback
C:\Users\Public\drop

How to read it: Hardcoded URL and path are leads for IOC hunting — not proof by themselves.

Common mistakes

  • Assuming every string is a live C2
  • Running on production binaries you must not reverse
xxd / hexdump— Hex dump of file bytes. Helps spot magic headers (MZ, ELF, PNG) and null…

What it does

Hex dump of file bytes. Helps spot magic headers (MZ, ELF, PNG) and null-padded secrets.

Syntax

xxd [file]

Important flags / options

  • -lLimit bytes
  • -sSeek offset

Example (lab)

xxd -l 16 flag.png

Example output

00000000: 8950 4e47 0d0a 1a0a 0000 000d 4948 4452  .PNG........IHDR

How to read it: 89504E47 is the PNG signature — file type matches extension.

Common mistakes

  • Dumping entire huge files to the terminal
df / du— df shows filesystem free space; du measures directory size. Disk-full ho…

What it does

df shows filesystem free space; du measures directory size. Disk-full hosts break logging and updates — both matter for availability and IR.

Syntax

df -h ; du -sh [path]

Important flags / options

  • df -hHuman sizes
  • du -sh *Per-item sizes
  • du -xOne filesystem

Example (lab)

du -sh /var/log/* | sort -h | tail

Example output

2.1G  /var/log/journal

How to read it: Journal is the space hog — tune retention before the disk fills.

Common mistakes

  • du on network mounts without knowing size
  • Ignoring inode exhaustion (df -i)
mount / lsblk— Inventory block devices and mounted filesystems. Look for unexpected USB…

What it does

Inventory block devices and mounted filesystems. Look for unexpected USB, loop devices, or world-writable mounts in hardening labs.

Syntax

lsblk ; mount

Important flags / options

  • lsblk -fWith FS types
  • findmntTree view of mounts

Example (lab)

lsblk -f

Example output

NAME FSTYPE LABEL MOUNTPOINT
sda1 ext4   root  /
sdb1 vfat   LAB   /media/usb

How to read it: An extra USB volume is mounted — document it in your lab notes.

Common mistakes

  • Unmounting busy system partitions
lsof— Lists open files and the processes that hold them. Classic for 'which pr…

What it does

Lists open files and the processes that hold them. Classic for 'which process has this port/file?' during IR.

Syntax

lsof [options]

Important flags / options

  • -i :PORTWho holds a port
  • -p PIDFiles for a process
  • -u userBy user

Example (lab)

sudo lsof -i :22

Example output

sshd 812 root 3u IPv4 … TCP *:ssh (LISTEN)

How to read it: PID 812 (sshd) owns the SSH listener — matches ss/netstat findings.

Common mistakes

  • Running without sudo and missing root-owned sockets
strace— Traces system calls. Powerful for debugging 'permission denied' or seein…

What it does

Traces system calls. Powerful for debugging 'permission denied' or seeing what a binary opens — use only on lab processes you own.

Syntax

strace -p PID | strace cmd

Important flags / options

  • -e open,openatFilter syscalls
  • -o fileWrite output
  • -fFollow children

Example (lab)

strace -e openat cat /etc/hosts 2>&1 | head

Example output

openat(AT_FDCWD, "/etc/hosts", O_RDONLY) = 3

How to read it: Confirms the file open succeeded with fd 3.

Common mistakes

  • Attaching to production critical processes
  • Flooding disk with -f on busy services
sudo / su— sudo runs one command as another user (usually root) with an audit trail…

What it does

sudo runs one command as another user (usually root) with an audit trail; su switches sessions. Least privilege means sudoers rules, not password-sharing.

Syntax

sudo [command] ; su - [user]

Important flags / options

  • -lList allowed commands
  • -u userRun as user
  • su -Login shell as root

Example (lab)

sudo -l

Example output

User alice may run:
    (ALL) NOPASSWD: /usr/bin/systemctl restart nginx

How to read it: Alice can restart nginx without a password — review whether that is intentional.

Common mistakes

  • NOPASSWD: ALL in sudoers
  • Leaving root shells open on shared hosts
crontab— Per-user scheduled jobs. Persistence hunters check user and system cront…

What it does

Per-user scheduled jobs. Persistence hunters check user and system crontabs (/etc/cron.*) for unexpected wget/curl reverse shells.

Syntax

crontab -l ; crontab -e

Important flags / options

  • -lList
  • -eEdit
  • -u userAnother user's crontab (root)

Example (lab)

crontab -l

Example output

*/5 * * * * /home/alice/backup.sh

How to read it: A backup runs every 5 minutes — verify the script contents and permissions.

Common mistakes

  • World-writable cron scripts
  • Ignoring /etc/cron.d and systemd timers
history— Shows shell command history for the current user. Great for self-review …

What it does

Shows shell command history for the current user. Great for self-review after a lab; attackers also scrape it for secrets — clear or avoid putting tokens on the CLI.

Syntax

history

Important flags / options

  • !nRe-run entry n
  • HISTCONTROLIgnore duplicates/spaces

Example (lab)

history | tail -5

Example output

 501  nmap -sV 10.0.0.5
 502  ssh alice@10.0.0.5

How to read it: Recent recon and login commands — useful for your lab write-up.

Common mistakes

  • Putting passwords on the command line
  • Assuming history is empty after closing the terminal
env / export— Shows or sets environment variables. Secrets in ENV are a common leak (C…

What it does

Shows or sets environment variables. Secrets in ENV are a common leak (CI logs, crash dumps, docker inspect).

Syntax

env ; export NAME=value

Important flags / options

  • env -iClean environment
  • printenv NAMEOne variable

Example (lab)

printenv | grep -i key

Example output

AWS_ACCESS_KEY_ID=AKIA…

How to read it: An access key is in the environment — rotate it and move to a secrets manager in real work.

Common mistakes

  • Committing .env files
  • echo $SECRET in shared screen shares
tar / gzip— Create or extract compressed archives. Verify contents before extracting…

What it does

Create or extract compressed archives. Verify contents before extracting untrusted tarballs (path traversal / zip-slip style issues).

Syntax

tar -czvf archive.tgz dir/

Important flags / options

  • -cCreate
  • -xExtract
  • -zgzip
  • -tList
  • -vVerbose

Example (lab)

tar -tzf lab-backup.tgz | head

Example output

./etc/passwd
./home/alice/.ssh/id_ed25519

How to read it: Archive contains a private key — handle as sensitive evidence, do not extract into a shared folder.

Common mistakes

  • Extracting as root into /
  • Blindly untarring internet downloads
scp / rsync— Copy files over SSH. Prefer keys over passwords; restrict which hosts yo…

What it does

Copy files over SSH. Prefer keys over passwords; restrict which hosts you push to. rsync can resume and exclude patterns.

Syntax

scp file user@host:path ; rsync -avz src/ dest/

Important flags / options

  • -Pscp preserve + progress
  • rsync -nDry run
  • --excludeSkip paths

Example (lab)

rsync -avz --dry-run ./web/ alice@lab:/var/www/html/

Example output

sending incremental file list
index.html

How to read it: Dry-run shows what would sync — review before a real deploy to your lab VM.

Common mistakes

  • scp -r of node_modules by accident
  • Trusting host keys without verification the first time
ssh— Secure remote shell. Harden with key auth, disabled root login, and Fail…

What it does

Secure remote shell. Harden with key auth, disabled root login, and Fail2ban/allowlists. Always verify host keys on first connect.

Syntax

ssh [user@]host [command]

Important flags / options

  • -i keyIdentity file
  • -LLocal port forward
  • -vVerbose debug

Example (lab)

ssh -i ~/.ssh/lab_ed25519 alice@192.168.56.10

Example output

Welcome to Ubuntu 22.04…

How to read it: Interactive session opened on the lab VM as alice.

Common mistakes

  • Password auth on internet-exposed SSH
  • Accepting changed host keys without investigating
kill / killall— Sends a signal to a process (default SIGTERM). Use after identifying the…

What it does

Sends a signal to a process (default SIGTERM). Use after identifying the PID with ps/pgrep — do not kill random system PIDs.

Syntax

kill [-SIGNAL] PID

Important flags / options

  • -9SIGKILL (last resort)
  • -HUPReload many daemons
  • pgrep -a nameFind PIDs

Example (lab)

pgrep -a python

Example output

2048 python3 -m http.server 8000

How to read it: Lab web server is PID 2048 — safe candidate to stop after practice.

Common mistakes

  • kill -9 as first choice
  • Killing PID 1
top / htop— Live process monitor for CPU/memory. Spike investigation starts here bef…

What it does

Live process monitor for CPU/memory. Spike investigation starts here before diving into logs.

Syntax

top ; htop

Important flags / options

  • PSort CPU (top)
  • MSort memory
  • kKill from within top

Example (lab)

top -bn1 | head -15

Example output

PID USER %CPU %MEM COMMAND
2048 alice 80.0 2.1 python3

How to read it: Python holding 80% CPU — expected if you left a busy lab script running.

Common mistakes

  • Leaving top fullscreen while missing alerts elsewhere
ufw— Uncomplicated Firewall front-end on Ubuntu. Default deny incoming is a s…

What it does

Uncomplicated Firewall front-end on Ubuntu. Default deny incoming is a solid lab hardening baseline.

Syntax

ufw [enable|allow|deny|status]

Important flags / options

  • status verboseRules + defaults
  • allow 22/tcpPermit SSH
  • deny out 53Example deny

Example (lab)

sudo ufw status verbose

Example output

Status: active
Default: deny (incoming), allow (outgoing)
22/tcp ALLOW IN Anywhere

How to read it: SSH is allowed; everything else inbound is denied — good minimal posture for a lab VM.

Common mistakes

  • Enabling ufw before allowing SSH (lockout)
  • allow 0.0.0.0/0 to every port
fail2ban-client— Shows Fail2ban jails that ban abusive IPs (often sshd). Confirm bans aft…

What it does

Shows Fail2ban jails that ban abusive IPs (often sshd). Confirm bans after simulated brute force in a lab.

Syntax

fail2ban-client status [jail]

Important flags / options

  • status sshdSSH jail
  • set sshd unbanip IPUnban

Example (lab)

sudo fail2ban-client status sshd

Example output

Currently banned: 1
Banned IP list: 203.0.113.50

How to read it: One attacker IP is banned — correlate with auth.log failures.

Common mistakes

  • Whitelisting your own IP incorrectly
  • Disabling the jail instead of tuning findtime
base64— Encode/decode Base64. Appearances in phishing, JWT payloads, and configs…

What it does

Encode/decode Base64. Appearances in phishing, JWT payloads, and configs — encoding is not encryption.

Syntax

base64 [file] ; base64 -d

Important flags / options

  • -w0No wrap
  • -dDecode

Example (lab)

echo -n 'admin:labpass' | base64

Example output

YWRtaW46bGFicGFzcw==

How to read it: Decoded later yields admin:labpass — anyone who sees the Base64 can recover it.

Common mistakes

  • Treating Base64 as a secret vault
  • Pasting production tokens into online decoders
jq— Query and pretty-print JSON. Essential for API security labs, cloud CLI …

What it does

Query and pretty-print JSON. Essential for API security labs, cloud CLI output, and JWT payloads.

Syntax

jq 'filter' file.json

Important flags / options

  • .Pretty print
  • .users[].idMap field
  • -rRaw strings

Example (lab)

echo '{"users":[{"id":1,"role":"admin"}]}' | jq '.users[0].role'

Example output

"admin"

How to read it: Extracted the role claim — useful when reviewing API responses for overexposure.

Common mistakes

  • Assuming jq is installed everywhere
  • Piping secrets into shell history via echo
hostname— Prints or sets the system hostname. During IR and inventory, hostname + …

What it does

Prints or sets the system hostname. During IR and inventory, hostname + /etc/hosts mismatches cause confusing DNS and cert errors.

Syntax

hostname [options]

Important flags / options

  • -fFQDN if configured
  • -IAll IP addresses
  • ctl hostnamectlsystemd hostname metadata

Example (lab)

hostname -f; hostname -I

Example output

lab-web.internal
192.168.56.10 10.0.3.15

How to read it: FQDN is lab-web.internal with two addresses — pick the correct interface when writing firewall rules.

Common mistakes

  • Changing hostname without updating certs/DNS
  • Relying on hostname alone for allowlists
netstat -plant (Linux)— Classic listening-port snapshot. Deprecated on many distros but still in…

What it does

Classic listening-port snapshot. Deprecated on many distros but still in exam objectives and old runbooks — know how to read it and how to migrate to ss.

Syntax

netstat -tulpn

Important flags / options

  • -tulpnTCP/UDP listen + PID/program
  • -anAll numeric

Example (lab)

sudo netstat -tulpn | head

Example output

Proto Recv-Q Send-Q Local Address  Foreign Address  State   PID/Program
tcp   0      0      0.0.0.0:22     0.0.0.0:*         LISTEN  812/sshd

How to read it: sshd owns *:22 — same conclusion as ss -tlnp.

Common mistakes

  • Assuming netstat exists in minimal containers
fuser— Shows which PIDs use a file, mount, or TCP/UDP port. Pair with ss/lsof w…

What it does

Shows which PIDs use a file, mount, or TCP/UDP port. Pair with ss/lsof when you need to free a port or unmount a busy disk.

Syntax

fuser -v port/tcp ; fuser -k file

Important flags / options

  • -vVerbose
  • -kKill processes (dangerous)
  • -n tcpNamespace tcp
  • 8080/tcpPort syntax

Example (lab)

sudo fuser -v 8000/tcp

Example output

                     USER  PID ACCESS COMMAND
8000/tcp:            alice 2048 F….  python

How to read it: PID 2048 (python) holds TCP 8000 — stop that lab http.server before binding another service.

Common mistakes

  • fuser -k on production listeners
  • Confusing ACCESS codes without man fuser
lsof -i— Open files + Internet sockets. When ss lacks process names (permissions)…

What it does

Open files + Internet sockets. When ss lacks process names (permissions), lsof often still maps port → binary.

Syntax

lsof -i :port ; lsof -iTCP -sTCP:LISTEN

Important flags / options

  • -i :443Anything on 443
  • -iTCP -sTCP:LISTENAll TCP listeners
  • -p PIDFiles for one process

Example (lab)

sudo lsof -iTCP:22 -sTCP:LISTEN

Example output

COMMAND PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
sshd    812 root   3u  IPv4  …      0t0  TCP *:ssh (LISTEN)

How to read it: Confirms sshd PID 812 — cross-check with ps and audit authorized_keys if you suspect compromise.

Common mistakes

  • Running lsof without sudo and missing root sockets
ufw status numbered— Readable firewall status with rule numbers for deletes. Good teaching br…

What it does

Readable firewall status with rule numbers for deletes. Good teaching bridge from iptables complexity to intent-based rules.

Syntax

sudo ufw status numbered

Important flags / options

  • status verboseDefaults + rules
  • delete NRemove by number
  • allow/denyAdd rules

Example (lab)

sudo ufw status numbered

Example output

Status: active
     To    Action  From
[ 1] 22/tcp ALLOW IN Anywhere

How to read it: Only SSH is allowed inbound — tighten further with allow from lab subnet if exposed.

Common mistakes

  • Enabling ufw before allowing SSH
ssh -vvv— Maximum SSH client verbosity — see which auth methods are offered, wheth…

What it does

Maximum SSH client verbosity — see which auth methods are offered, whether keys are tried, and where negotiation fails.

Syntax

ssh -vvv user@host

Important flags / options

  • -vvvDebug level 3
  • -i keyIdentity file
  • -o PreferredAuthentications=publickeyForce method

Example (lab)

ssh -vvv -i ~/.ssh/lab_ed25519 alice@192.168.56.10

Example output

debug1: Offering public key: …
debug1: Authentication succeeded (public key).

How to read it: Publickey succeeded — if it fails earlier, check permissions on key files (600) and server authorized_keys.

Common mistakes

  • Pastings -vvv logs that contain sensitive env into tickets without redaction
scp— Copy files over SSH. Prefer explicit paths and dry mental checks before …

What it does

Copy files over SSH. Prefer explicit paths and dry mental checks before -r of huge trees.

Syntax

scp [-r] source user@host:path

Important flags / options

  • -rRecursive
  • -P portSSH port (capital P)
  • -i keyIdentity
  • -CCompression

Example (lab)

scp -i ~/.ssh/lab_ed25519 ./notes.md alice@192.168.56.10:~/notes.md

Example output

notes.md                                    100% 4096   1.2MB/s   00:00

How to read it: File landed in alice’s home — verify checksums for critical artifacts.

Common mistakes

  • scp -r / with a trailing mistake
  • Using password auth on internet-exposed SSH
rsync over SSH— Efficient sync for lab backups and deploy folders. Dry-run first (-n) so…

What it does

Efficient sync for lab backups and deploy folders. Dry-run first (-n) so you do not delete remote files by accident.

Syntax

rsync -avz -e ssh src/ user@host:dest/

Important flags / options

  • -aArchive mode
  • -vVerbose
  • -zCompress
  • -nDry run
  • --deleteMirror deletes (dangerous)

Example (lab)

rsync -avzn -e 'ssh -i ~/.ssh/lab_ed25519' ./web/ alice@192.168.56.10:/var/www/html/

Example output

sending incremental file list
index.html
assets/app.css

How to read it: Dry-run shows two paths would sync — drop -n to perform after review.

Common mistakes

  • --delete without backups
  • Syncing .env into a world-readable web root
systemctl restart / status— Control systemd services during lab hardening. Always status before/afte…

What it does

Control systemd services during lab hardening. Always status before/after restart so you can prove the change.

Syntax

sudo systemctl status|restart|reload UNIT

Important flags / options

  • statusActive state + recent logs
  • restartStop then start
  • reloadReload config if supported
  • is-enabledBoot persistence

Example (lab)

sudo systemctl status nginx --no-pager -l

Example output

● nginx.service - A high performance web server
   Active: active (running)

How to read it: nginx is active — if curl still fails, check listen address and firewall next.

Common mistakes

  • restart sshd after locking yourself out of key auth
  • masking critical units without documentation
journalctl -u— Service-centric logs for connectivity failures (nginx 502, sshd refused …

What it does

Service-centric logs for connectivity failures (nginx 502, sshd refused key, NetworkManager).

Syntax

journalctl -u UNIT -n 50 --no-pager

Important flags / options

  • -uUnit
  • -fFollow
  • --since '10 min ago'Time window
  • -p errPriority filter

Example (lab)

journalctl -u ssh -n 20 --no-pager

Example output

sshd[812]: Accepted publickey for alice from 192.168.56.50

How to read it: Successful key login from your workstation IP — baseline for detecting later brute force.

Common mistakes

  • journalctl without time bounds on busy hosts

Networking (35)

ping— ICMP echo request/reply for reachability and rough latency. Firewalls of…

What it does

ICMP echo request/reply for reachability and rough latency. Firewalls often drop ICMP, so silence ≠ proof the host is down.

Syntax

ping [options] host

Important flags / options

  • -c NStop after N probes
  • -WTimeout
  • -nNumeric (no reverse DNS)

Example (lab)

ping -c 3 127.0.0.1

Example output

64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.04 ms

How to read it: Loopback answers — stack is up. TTL and time help spot distant vs local hops later.

Common mistakes

  • Infinite ping flooding a link
  • Assuming no reply means offline
traceroute— Lists routers (hops) on the path to a destination. Helps explain where l…

What it does

Lists routers (hops) on the path to a destination. Helps explain where latency or filtering appears; many hops show * when ICMP is rate-limited.

Syntax

traceroute host

Important flags / options

  • -nSkip DNS lookups
  • -IICMP probes
  • -TTCP probes (when ICMP blocked)

Example (lab)

traceroute -n 1.1.1.1

Example output

1 192.168.1.1 1.2 ms
2 10.0.0.1 8.1 ms

How to read it: Hop 1 is your LAN gateway; hop 2 is upstream. * * * later would mean no reply, not always a black hole.

Common mistakes

  • Treating * as definitive failure
  • Running against targets outside lab/ISP norms repeatedly
nslookup— Interactive/simple DNS query tool (legacy). Fine for a quick A record; u…

What it does

Interactive/simple DNS query tool (legacy). Fine for a quick A record; use dig for serious DNS work (any type, +trace, DNSSEC flags).

Syntax

nslookup name [server]

Example (lab)

nslookup example.com

Example output

Name: example.com
Address: 93.184.215.14

How to read it: Got an A record from the configured resolver — note which server answered if you set one.

Common mistakes

  • Stopping at nslookup when dig is available
  • Ignoring TTL and caching behavior
dig— The flexible DNS Swiss Army knife: any RR type, short or verbose, specif…

What it does

The flexible DNS Swiss Army knife: any RR type, short or verbose, specific resolvers, and +trace. Core for phishing domain checks and mail (MX/TXT/SPF) labs.

Syntax

dig [@server] name [type]

Important flags / options

  • +shortOne-line answers
  • MX/TXT/NS/ARecord type
  • @1.1.1.1Query that resolver
  • +traceWalk from root

Example (lab)

dig example.com MX +short

Example output

0 .

How to read it: Null MX (priority 0, host ".") — domain publishes that it accepts no mail. Useful anti-abuse signal.

Common mistakes

  • Forgetting the type and only seeing A
  • Assuming dig validates DNSSEC without +dnssec/+adflag attention
ip— iproute2 toolkit: addresses, links, routes, neighbors. Replaces ifconfig…

What it does

iproute2 toolkit: addresses, links, routes, neighbors. Replaces ifconfig/route on modern Linux.

Syntax

ip [object] [command]

Important flags / options

  • a / addrAddresses
  • l / linkInterfaces up/down
  • r / routeRouting table
  • n / neighARP/NDP cache

Example (lab)

ip a

Example output

2: eth0: … inet 192.168.56.10/24

How to read it: eth0 has a Host-Only/lab IP in a /24 — use this when configuring nmap targets in VirtualBox/VMware labs.

Common mistakes

  • ip addr add without netplan/NetworkManager persist
  • Bringing down the only SSH interface remotely
tcpdump— CLI packet capture. Learn BPF filters (host, port, net) and always write…

What it does

CLI packet capture. Learn BPF filters (host, port, net) and always write -w pcaps for Wireshark later. Capture only on networks you own.

Syntax

tcpdump [options] [bpf filter]

Important flags / options

  • -iInterface (lo, eth0, any)
  • -nnNo name/port resolve
  • -w file.pcapWrite capture
  • -c NStop after N packets
  • port 80BPF example

Example (lab)

sudo tcpdump -i lo -nn port 8000 -c 4

Example output

IP 127.0.0.1.51234 > 127.0.0.1.8000: Flags [S]

How to read it: SYN to port 8000 on loopback — TCP handshake start for your local lab server.

Common mistakes

  • Wrong interface (empty capture)
  • Capturing on corporate Wi‑Fi without authorization
arp— Shows ARP cache (IP→MAC).

What it does

Shows ARP cache (IP→MAC).

Syntax

arp -a

Example (lab)

arp -a

Example output

192.168.1.1 at aa:bb:…

How to read it: Useful when hunting spoofing in a lab LAN.

Common mistakes

  • Trusting ARP on hostile networks
route / ip route— Shows routing table.

What it does

Shows routing table.

Syntax

ip route

Example (lab)

ip route

Example output

default via 192.168.1.1 dev eth0

How to read it: Default gateway and interfaces.

Common mistakes

  • Changing routes without documenting
nc— Netcat — connect or listen for lab tests.

What it does

Netcat — connect or listen for lab tests.

Syntax

nc [options] host port

Important flags / options

  • -lListen
  • -vVerbose
  • -zScan without data

Example (lab)

nc -lv 9000

Example output

listening on [any] 9000 …

How to read it: Simple lab listener for connectivity tests.

Common mistakes

  • Exposing listeners on public interfaces
iptables— Legacy Linux firewall (still common).

What it does

Legacy Linux firewall (still common).

Syntax

iptables [-t table] -A CHAIN rule

Important flags / options

  • -LList rules
  • -A INPUTAppend input rule

Example (lab)

sudo iptables -L -n -v

Example output

Chain INPUT (policy ACCEPT) …

How to read it: Review allow/deny before audits.

Common mistakes

  • Flushing rules remotely and locking yourself out
nft— Modern netfilter firewall CLI.

What it does

Modern netfilter firewall CLI.

Syntax

nft list ruleset

Important flags / options

  • add ruleAdd rule

Example (lab)

sudo nft list ruleset

Example output

table inet filter { … }

How to read it: Preferred on newer distros.

Common mistakes

  • Mixing iptables-nft and nft syntax incorrectly
ip route— Show/manipulate routing table.

What it does

Show/manipulate routing table.

Syntax

ip route [show|add|del]

Example (lab)

ip route show default

Example output

default via 192.168.1.1 dev eth0

How to read it: Verify default gateway and routes.

Common mistakes

  • Adding routes without documenting
ethtool— NIC driver/link settings.

What it does

NIC driver/link settings.

Syntax

ethtool iface

Example (lab)

ethtool eth0

Example output

Speed: 1000Mb/s Duplex: Full

How to read it: Link diagnostics.

Common mistakes

  • Changing settings on production NICs casually
tshark— CLI Wireshark — capture/analyze pcaps.

What it does

CLI Wireshark — capture/analyze pcaps.

Syntax

tshark [options]

Important flags / options

  • -rRead pcap
  • -YDisplay filter

Example (lab)

tshark -r lab.pcap -Y 'http.request.method==POST'

Example output

POST frames listed

How to read it: Automate packet analysis in scripts.

Common mistakes

  • Capturing on wrong interface
python3 -m http.server— Quick static file server for labs. Bind carefully — serving your home di…

What it does

Quick static file server for labs. Bind carefully — serving your home directory on 0.0.0.0 exposes files to the LAN.

Syntax

python3 -m http.server [port]

Important flags / options

  • 8000Port
  • --bind 127.0.0.1Localhost only

Example (lab)

python3 -m http.server 8000 --bind 127.0.0.1

Example output

Serving HTTP on 127.0.0.1 port 8000 …

How to read it: Only your machine can reach it — safer for local demos.

Common mistakes

  • Serving / as root
  • Leaving it on 0.0.0.0 on café Wi‑Fi
httpie / curl -X— Craft arbitrary HTTP requests. Core skill for API testing on apps you ow…

What it does

Craft arbitrary HTTP requests. Core skill for API testing on apps you own: verbs, auth headers, and content types.

Syntax

curl -X METHOD -H 'Header: v' -d 'body' URL

Important flags / options

  • -HHeader
  • -dBody
  • -u user:passBasic auth
  • -kInsecure TLS (lab only)

Example (lab)

curl -s -X POST http://127.0.0.1:5000/login -H "Content-Type: application/json" -d '{"user":"alice","pass":"lab"}'

Example output

{"token":"eyJhbGciOiJub25lIn0…"}

How to read it: Login returned a JWT — next step is decode claims (alg, exp, role) in your lab notes.

Common mistakes

  • -k on production
  • Putting real passwords in shell history
wireshark display filters— Display filters hide noise so you can study protocols. Learn a few: ip.a…

What it does

Display filters hide noise so you can study protocols. Learn a few: ip.addr, tcp.port, http.host, dns.qry.name, tls.handshake.type.

Syntax

(in Wireshark) http.request || dns.qry.name

Important flags / options

  • ==Equals
  • containsSubstring
  • && / ||Combine

Example (lab)

http.request and http.host == "lab.local"

Example output

(packet list shows only matching HTTP requests)

How to read it: Focuses the capture on one virtual host during a web lab.

Common mistakes

  • Confusing capture filters (BPF) with display filters
mtr— My Traceroute — live updating combination of ping + traceroute. Best fir…

What it does

My Traceroute — live updating combination of ping + traceroute. Best first tool when users say “the network is flaky” on a path you own (lab or corp WAN).

Syntax

mtr [-r] [-c count] host

Important flags / options

  • -r / --reportSend report then exit
  • -c NCycles
  • -nNumeric (no DNS)
  • -zAS lookups (when available)

Example (lab)

mtr -rwc 20 -n 192.168.56.10

Example output

HOST: labbox    Loss%  Snt  Last  Avg  Best  Wrst
1.|-- 192.168.56.1   0.0%  20   0.4  0.5  0.3  1.1
2.|-- 192.168.56.10  0.0%  20   0.6  0.7  0.4  1.4

How to read it: Stable low Avg/Wrst and 0% Loss → clean lab path. Rising Loss% on one hop suggests congestion or filtering there.

Common mistakes

  • Installing mtr on production without change control
  • Panic on loss at hops that simply do not answer ICMP
ping6 / traceroute6— IPv6 reachability and path tools. Dual-stack labs break when v4 works bu…

What it does

IPv6 reachability and path tools. Dual-stack labs break when v4 works but v6 is misconfigured (or vice versa).

Syntax

ping6 -c 3 addr ; traceroute6 addr

Important flags / options

  • -c NCount (ping6)
  • -nNumeric traceroute6

Example (lab)

ping6 -c 3 fe80::1%eth0

Example output

64 bytes from fe80::1%eth0: icmp_seq=1 ttl=64 time=0.3 ms

How to read it: Link-local reply on eth0 proves L2/L3 IPv6 on that interface — note the %eth0 scope id.

Common mistakes

  • Forgetting the interface scope on link-local addresses
  • Assuming no AAAA means IPv6 is “broken” globally
ifconfig— Legacy interface config (still on many BSD/old Linux images). Prefer `ip…

What it does

Legacy interface config (still on many BSD/old Linux images). Prefer `ip` on modern Linux, but you must read ifconfig output in older write-ups and CTF boxes.

Syntax

ifconfig [iface]

Important flags / options

  • ifaceShow one interface
  • iface up/downBring interface up/down (needs root)

Example (lab)

ifconfig eth0

Example output

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.56.10  netmask 255.255.255.0  broadcast 192.168.56.255

How to read it: eth0 is UP with 192.168.56.10/24 — same story as `ip a`, older syntax.

Common mistakes

  • Teaching only ifconfig on Ubuntu 22+ (use ip)
  • ifconfig down on your only SSH interface
ip link / ip addr— Brief view of link state and addresses — fastest “cable plugged in?” che…

What it does

Brief view of link state and addresses — fastest “cable plugged in?” check on Linux labs.

Syntax

ip -br link ; ip -br addr

Important flags / options

  • -brBrief columns
  • link set eth0 upAdmin-up the NIC
  • addr add …/24 dev eth0Add address

Example (lab)

ip -br addr

Example output

lo               UNKNOWN        127.0.0.1/8 ::1/128
eth0             UP             192.168.56.10/24

How to read it: eth0 UP with a /24 address → L2+L3 look healthy; if DOWN, check cable/hypervisor NIC attachment.

Common mistakes

  • Adding secondary IPs without documenting
  • Confusing admin DOWN with cable unplugged
ip neigh— Neighbor table (ARP/NDP). Stale or wrong MAC mappings appear during ARP …

What it does

Neighbor table (ARP/NDP). Stale or wrong MAC mappings appear during ARP spoof labs and after VM MAC changes.

Syntax

ip neigh show

Important flags / options

  • showList cache
  • flush allClear cache (careful)

Example (lab)

ip neigh show dev eth0

Example output

192.168.56.1 lladdr 0a:00:27:00:00:01 REACHABLE

How to read it: Gateway MAC is cached and REACHABLE — good. FAILED/INCOMPLETE means no ARP reply.

Common mistakes

  • Flushing neigh on production during peak
  • Trusting ARP on hostile networks
nmcli— NetworkManager CLI — inspect and control connections on desktop/server i…

What it does

NetworkManager CLI — inspect and control connections on desktop/server images that use NM. Handy when `ip` shows an address but “the GUI wifi” is wrong.

Syntax

nmcli device status ; nmcli connection show

Important flags / options

  • device statusDevice overview
  • connection up NAMEActivate profile
  • dev wifiWi‑Fi scan (authorized networks)

Example (lab)

nmcli device status

Example output

DEVICE  TYPE      STATE      CONNECTION
eth0    ethernet  connected  Wired connection 1
wlan0   wifi      disconnected  --

How to read it: Ethernet connected; Wi‑Fi idle — expected for a wired lab VM.

Common mistakes

  • nmcli connection delete on the wrong profile
  • Connecting to untrusted SSIDs during a red-team engagement without rules
curl -v / TLS triage— Verbose curl shows DNS → TCP → TLS → HTTP. Use when browsers show generi…

What it does

Verbose curl shows DNS → TCP → TLS → HTTP. Use when browsers show generic errors but you need the failing layer.

Syntax

curl -vI https://host

Important flags / options

  • -vVerbose
  • -IHeaders only
  • -kInsecure TLS (lab only)
  • --resolve host:443:IPPin IP / bypass DNS

Example (lab)

curl -vI https://127.0.0.1:8443/ --resolve lab.local:8443:127.0.0.1 2>&1 | findstr /i "Connected SSL HTTP"

Example output

* Connected to 127.0.0.1 port 8443
* SSL connection using TLSv1.3
< HTTP/1.1 200 OK

How to read it: TCP connected, TLS negotiated, HTTP 200 — stack is healthy; look at app logic next.

Common mistakes

  • -k on production
  • Ignoring certificate verify return code
httpie— Human-friendly HTTP client (httpie). Great for API labs: readable JSON, …

What it does

Human-friendly HTTP client (httpie). Great for API labs: readable JSON, sessions, and auth headers without opaque curl strings.

Syntax

http [METHOD] URL field=value

Important flags / options

  • GET/POSTMethods
  • Authorization:Bearer …Header form
  • -vVerbose
  • --sessionPersist cookies

Example (lab)

http POST http://127.0.0.1:5000/login username=alice password=lab --print=HhBb

Example output

POST /login HTTP/1.1
…
HTTP/1.1 200 OK
{
    "token": "eyJ…"
}

How to read it: Login succeeded and returned a token — decode claims next; do not paste real tokens into public tools.

Common mistakes

  • Putting production secrets in shell history
  • Assuming httpie is installed on every jump box
wget spider— Check whether a URL responds without downloading the body — useful for m…

What it does

Check whether a URL responds without downloading the body — useful for monitoring lab endpoints and mirror health.

Syntax

wget --spider -S URL

Important flags / options

  • --spiderDo not save
  • -SShow server response
  • -O-Write body to stdout

Example (lab)

wget --spider -S http://127.0.0.1:8000/ 2>&1 | Select-String -Pattern 'HTTP|Length'

Example output

HTTP/1.0 200 OK
Length: unspecified

How to read it: Endpoint answers 200 — good smoke test before opening a browser.

Common mistakes

  • Spidering sites out of scope
  • Following redirects onto attacker-controlled hosts blindly
telnet— Legacy interactive TCP client. Still useful as a “is this port open and …

What it does

Legacy interactive TCP client. Still useful as a “is this port open and speaking cleartext?” probe (SMTP banner, HTTP). Prefer nc/Test-NetConnection when available.

Syntax

telnet host port

Example (lab)

telnet 127.0.0.1 80

Example output

Connected to 127.0.0.1.
Escape character is '^]'.

How to read it: TCP connect succeeded on port 80 — type a raw HTTP request or Ctrl+] quit. Connection refused means nothing listens.

Common mistakes

  • Leaving telnet enabled as a service (telnetd) on servers
  • Sending credentials in cleartext telnet sessions
netcat (nc)— Swiss-army TCP/UDP client/server for labs: port checks, simple transfers…

What it does

Swiss-army TCP/UDP client/server for labs: port checks, simple transfers, banner grabs. Same family as the shorter `nc` entry — focus here on troubleshooting patterns.

Syntax

nc [options] host port

Important flags / options

  • -zvScan without sending data (verbose)
  • -l -p PORTListen
  • -uUDP
  • -w NTimeout seconds

Example (lab)

nc -zv 192.168.56.10 22 80 443

Example output

Connection to 192.168.56.10 22 port [tcp/ssh] succeeded!
nc: connect to … 80 failed: Connection refused
Connection to … 443 succeeded!

How to read it: SSH and HTTPS open; HTTP closed — aligns with a TLS-only lab web server.

Common mistakes

  • nc -l on 0.0.0.0 in hostile networks
  • Using netcat reverse shells outside authorized labs
ss troubleshooting— Modern socket view for “what is listening?” and “who am I connected to?”…

What it does

Modern socket view for “what is listening?” and “who am I connected to?” Faster and more accurate than netstat on current Linux.

Syntax

ss -tulpn ; ss -tn state established

Important flags / options

  • -tulpnTCP/UDP listen + processes
  • state establishedActive connections
  • dst :443Filter destination port

Example (lab)

ss -tulpn | findstr /i ":22 :80 :443"

Example output

LISTEN 0 128 0.0.0.0:22 … users:(("sshd"…))
LISTEN 0 128 127.0.0.1:80 …

How to read it: SSH on all interfaces; HTTP only on localhost — HTTP is not exposed to the LAN (good unless you intended otherwise).

Common mistakes

  • Reading LISTEN on 127.0.0.1 as “open to the world”
iptables -L -n -v— List filter rules with packet counters. First stop when “ping works but …

What it does

List filter rules with packet counters. First stop when “ping works but port X does not” on legacy Linux firewalls.

Syntax

sudo iptables -L -n -v

Important flags / options

  • -LList
  • -nNumeric
  • -vCounters
  • -t natNAT table

Example (lab)

sudo iptables -L INPUT -n -v

Example output

Chain INPUT (policy DROP 0 packets, 0 bytes)
pkts bytes target     prot  …
120  9600 ACCEPT     tcp   --  *  *  0.0.0.0/0  0.0.0.0/0  tcp dpt:22

How to read it: Default DROP with SSH allowed — counters prove SSH traffic matched the accept rule.

Common mistakes

  • iptables -F over SSH (lockout)
  • Forgetting IPv6 ip6tables
sftp— Interactive file transfer over SSH. Useful when you need directory listi…

What it does

Interactive file transfer over SSH. Useful when you need directory listing and partial uploads without full scp paths memorized.

Syntax

sftp user@host

Important flags / options

  • ls/cd/put/getInteractive commands
  • -i keyIdentity

Example (lab)

sftp -i ~/.ssh/lab_ed25519 alice@192.168.56.10

Example output

Connected to 192.168.56.10.
sftp> put report.pdf
Uploading report.pdf to /home/alice/report.pdf

How to read it: Interactive session works — same auth as SSH; firewall must allow 22/tcp.

Common mistakes

  • Leaving SFTP chroots world-writable
tcpdump port filter— Confirm packets arrive when app logs are silent. Classic: SYN seen but n…

What it does

Confirm packets arrive when app logs are silent. Classic: SYN seen but no SYN-ACK → host firewall or service down.

Syntax

sudo tcpdump -ni iface port PORT -c N

Important flags / options

  • -nNo DNS
  • -iInterface
  • port 443BPF filter
  • -w file.pcapSave for Wireshark

Example (lab)

sudo tcpdump -ni eth0 port 22 -c 5

Example output

IP 192.168.56.50.51234 > 192.168.56.10.22: Flags [S]
IP 192.168.56.10.22 > 192.168.56.50.51234: Flags [S.]

How to read it: SYN and SYN-ACK exchanged — TCP handshake for SSH is healthy on the wire.

Common mistakes

  • Capturing on the wrong bridge in nested virt
  • Writing pcaps with secrets to shared folders
connectivity checklist— Study workflow (not a single binary): (1) link/IP with ip/ifconfig/ipcon…

What it does

Study workflow (not a single binary): (1) link/IP with ip/ifconfig/ipconfig (2) gateway ping (3) DNS dig/nslookup (4) TCP Test-NetConnection/nc (5) app curl/http (6) path mtr/traceroute if lossy. Use only on networks you own.

Syntax

# mental model: L1→L7

Important flags / options

  • L1/L2Cable, link state, ARP
  • L3IP, route, ping
  • L4ports ss/nc
  • L7HTTP/TLS/SSH

Example (lab)

ip -br addr; ping -c 2 192.168.56.1; dig +short lab-web.internal @192.168.56.2; nc -zv 192.168.56.10 22; curl -I http://192.168.56.10/

Example output

(each tool prints its own success/failure)

How to read it: Run top-down: if ping to gateway fails, do not debug HTTP yet. Document which layer first failed.

Common mistakes

  • Skipping DNS when the symptom is a hostname
  • Changing three things at once
firewall-cmd— firewalld CLI (RHEL/CentOS/Fedora). Parallel to ufw/iptables — know whic…

What it does

firewalld CLI (RHEL/CentOS/Fedora). Parallel to ufw/iptables — know which stack your lab distro uses.

Syntax

firewall-cmd --state ; firewall-cmd --list-all

Important flags / options

  • --stateRunning?
  • --list-allZones/ports
  • --add-port=443/tcpOpen port (runtime)
  • --permanentPersist across reboot

Example (lab)

sudo firewall-cmd --list-all

Example output

public
  target: default
  services: ssh
  ports:

How to read it: Only ssh service is allowed in public zone — add http/https deliberately for web labs.

Common mistakes

  • Opening ports permanently without --reload
  • Mixing firewalld and raw iptables unexpectedly
curl timing— Break down where latency lives: DNS vs TCP vs TLS vs server think time. …

What it does

Break down where latency lives: DNS vs TCP vs TLS vs server think time. Perfect for “site is slow” tickets on systems you own.

Syntax

curl -o NUL -s -w "dns:%{time_namelookup} connect:%{time_connect} tls:%{time_appconnect} ttfb:%{time_starttransfer} total:%{time_total}\n" URL

Important flags / options

  • -wWrite-out format
  • -o NUL / -o /dev/nullDiscard body
  • -sSilent progress

Example (lab)

curl -o /dev/null -s -w "dns:%{time_namelookup} connect:%{time_connect} tls:%{time_appconnect} ttfb:%{time_starttransfer} total:%{time_total}\n" https://example.com/

Example output

dns:0.012 connect:0.045 tls:0.120 ttfb:0.210 total:0.215

How to read it: TLS and TTFB dominate — optimize certificate/chain and origin app, not just DNS.

Common mistakes

  • Comparing timings across different networks without noting Wi‑Fi vs ethernet

Security (18)

nmap— Port/service discovery and scriptable checks. Legal/ethical boundary: on…

What it does

Port/service discovery and scriptable checks. Legal/ethical boundary: only scan systems you own or have written authorization for (plus official scanme.nmap.org).

Syntax

nmap [options] target

Important flags / options

  • -sVService/version detection
  • -sCDefault NSE scripts
  • -pPort list or -p-
  • -oA nameSave .nmap/.xml/.gnmap
  • -PnSkip host discovery

Example (lab)

nmap -sV localhost

Example output

22/tcp open ssh OpenSSH 9.6
8000/tcp open http SimpleHTTPServer

How to read it: Two open services with versions — feed these into CVE research for your lab hardening notes.

Common mistakes

  • Unauthorized internet scanning
  • -p- + aggressive timing against fragile prod
openssl— TLS, X.509, hashing, and key utilities. Inspect remote certs with s_clie…

What it does

TLS, X.509, hashing, and key utilities. Inspect remote certs with s_client; hash files with dgst; never paste production private keys into random sites.

Syntax

openssl <subcommand> [options]

Important flags / options

  • s_clientSpeak TLS to a server
  • x509Cert encode/decode
  • dgstMessage digest
  • rand -hexRandom bytes

Example (lab)

echo -n hello | openssl dgst -sha256

Example output

SHA2-256(stdin)= 2cf24dba5fb0a30e...

How to read it: Hash of the four characters h-e-l-l-o. Missing echo -n adds a newline and a different digest.

Common mistakes

  • echo without -n when matching published hashes
  • openssl s_client and ignoring verify return code
hashcat— GPU password recovery for auditing. Use only hashes you are authorized t…

What it does

GPU password recovery for auditing. Use only hashes you are authorized to test (your lab dumps, your org’s audit). Mode -m must match the hash format.

Syntax

hashcat -m MODE -a ATTACK hashes wordlist

Important flags / options

  • -m 0MD5
  • -m 1000NTLM
  • -a 0Dictionary
  • -a 3Mask attack
  • --showPrint cracked

Example (lab)

hashcat -m 0 -a 0 lab.txt rockyou.txt

Example output

5f4dcc3b5aa765d61d8327deb882cf99:password

How to read it: Lab MD5 cracked to "password" — teach longer unique passwords + hashing with salt/slow KDFs.

Common mistakes

  • Wrong -m mode (silent fails)
  • Cracking leaked dumps you do not own
john— John the Ripper — CPU-friendly password auditor. Good when GPU hashcat i…

What it does

John the Ripper — CPU-friendly password auditor. Good when GPU hashcat is unavailable; still lab/authorized hashes only.

Syntax

john [options] hashfile

Important flags / options

  • --wordlist=FILEDictionary
  • --showShow cracked
  • --format=Force hash type
  • --rulesWordlist mangling

Example (lab)

john --show lab.txt

Example output

user1:letmein

How to read it: Cracked pair ready for the lab report — then reset the account and document the weakness.

Common mistakes

  • Ambiguous hashes without --format
  • Leaving pot files with real credentials on shared VMs
openssl s_client— Debug a TLS handshake and view certificates.

What it does

Debug a TLS handshake and view certificates.

Syntax

openssl s_client -connect host:443

Important flags / options

  • -servernameSNI

Example (lab)

openssl s_client -connect example.com:443 -servername example.com

Example output

Certificate chain …

How to read it: Inspect cert subject/issuer and protocol.

Common mistakes

  • Ignoring certificate warnings in production clients
sha256sum— Compute SHA-256 of a file for integrity checks.

What it does

Compute SHA-256 of a file for integrity checks.

Syntax

sha256sum file

Example (lab)

sha256sum image.iso

Example output

ab12…  image.iso

How to read it: Compare to published hashes.

Common mistakes

  • Trusting hashes from the same untrusted mirror only
gpg— Verify signatures (lab/keyring dependent).

What it does

Verify signatures (lab/keyring dependent).

Syntax

gpg --verify file.sig file

Important flags / options

  • --verifyCheck signature

Example (lab)

gpg --verify SHA256SUMS.sig SHA256SUMS

Example output

Good signature from …

How to read it: Confirms authenticity when keys are trusted.

Common mistakes

  • Importing random keys without trust model
yara— Scan files with YARA rules in a malware lab.

What it does

Scan files with YARA rules in a malware lab.

Syntax

yara rules.yar file

Example (lab)

yara rules.yar sample.bin

Example output

RuleName sample.bin

How to read it: Rule matched the sample.

Common mistakes

  • Running unknown samples outside a sandbox
git log— Review history — also useful when hunting leaked secrets.

What it does

Review history — also useful when hunting leaked secrets.

Syntax

git log --oneline

Important flags / options

  • -pPatch
  • -SPickaxe search

Example (lab)

git log -S 'AKIA' --oneline

Example output

…commits mentioning pattern…

How to read it: Secret scanning starts with history awareness.

Common mistakes

  • Force-pushing to hide secrets instead of rotating
jwt-cli— Decode JWT header/payload (jwt-cli or similar).

What it does

Decode JWT header/payload (jwt-cli or similar).

Syntax

jwt decode TOKEN

Example (lab)

jwt decode eyJhbGci…

Example output

Header/Payload JSON

How to read it: Inspect alg/claims during API reviews.

Common mistakes

  • Pasting production tokens into public websites
nmap -sC -sV— Default script scan (-sC) plus version detection (-sV). Richer than a ba…

What it does

Default script scan (-sC) plus version detection (-sV). Richer than a bare port list — still only on authorized lab targets.

Syntax

nmap -sC -sV -p- target

Important flags / options

  • -sCDefault NSE scripts
  • -sVVersions
  • -p-All TCP ports
  • -oASave all formats

Example (lab)

nmap -sC -sV -p 22,80 127.0.0.1

Example output

22/tcp open ssh OpenSSH 9.6
80/tcp open http Apache httpd 2.4.57

How to read it: Versions feed CVE research; scripts may show http-title or ssh algorithms.

Common mistakes

  • -p- against production without scope
  • Trusting NSE output as exploit confirmation
nikto— Web server scanner for common misconfigurations and outdated software. N…

What it does

Web server scanner for common misconfigurations and outdated software. Noisy — lab and authorized assessments only.

Syntax

nikto -h URL

Important flags / options

  • -hHost/URL
  • -TuningSelect checks
  • -outputSave report

Example (lab)

nikto -h http://127.0.0.1:8080

Example output

+ Server: Apache/2.4.49
+ The anti-clickjacking X-Frame-Options header is not present.

How to read it: Missing security headers and an old Server banner are findings to verify manually.

Common mistakes

  • Running against third-party sites
  • Treating every plugin hit as critical without validation
ffuf— Fast web fuzzer for directories, parameters, and vhosts. Rate-limit and …

What it does

Fast web fuzzer for directories, parameters, and vhosts. Rate-limit and scope carefully even in labs.

Syntax

ffuf -u URL/FUZZ -w wordlist

Important flags / options

  • -uURL with FUZZ
  • -wWordlist
  • -mcMatch status codes
  • -eExtensions

Example (lab)

ffuf -u http://127.0.0.1:3000/FUZZ -w common.txt -mc 200,301,302

Example output

admin                   [Status: 301]
backup.zip              [Status: 200]

How to read it: Hidden admin path and a downloadable backup — high-value lab findings to report ethically.

Common mistakes

  • Huge wordlists without -rate
  • Fuzzing out-of-scope hosts
hydra (lab)— Online password guessing against lab services. Illegal/unethical without…

What it does

Online password guessing against lab services. Illegal/unethical without authorization — use only intentionally vulnerable VMs.

Syntax

hydra -l user -P wordlist proto://host

Important flags / options

  • -lSingle login
  • -LLogin list
  • -PPassword list
  • -tTasks/threads

Example (lab)

hydra -l admin -P rockyou-top100.txt ssh://192.168.56.20

Example output

[22][ssh] host: 192.168.56.20   login: admin   password: admin123

How to read it: Weak lab credential found — document and remediate (disable password auth / enforce MFA).

Common mistakes

  • Pointing at real internet hosts
  • High -t causing DoS on fragile labs
sqlmap (lab)— Automates SQL injection detection/exploitation against apps you own (e.g…

What it does

Automates SQL injection detection/exploitation against apps you own (e.g. DVWA). Always confirm findings manually for reports.

Syntax

sqlmap -u 'URL' --batch

Important flags / options

  • --batchNo prompts
  • --dbsList databases
  • --risk/--levelTest depth

Example (lab)

sqlmap -u "http://127.0.0.1/dvwa/vulnerabilities/sqli/?id=1&Submit=Submit" --cookie="security=low; PHPSESSID=…" --batch --dbs

Example output

available databases [2]:
[*] dvwa
[*] information_schema

How to read it: Confirmed injectable parameter and listed DBs — next teach parameterized queries as the fix.

Common mistakes

  • --os-shell on shared hosting
  • Using against production
nmap host discovery— Ping-scan / host discovery without port scanning. Map which lab VMs are …

What it does

Ping-scan / host discovery without port scanning. Map which lab VMs are up on a subnet you own.

Syntax

nmap -sn net/mask

Important flags / options

  • -snNo port scan
  • -PS22,80TCP SYN ping set
  • -PRARP ping (local LAN)

Example (lab)

nmap -sn 192.168.56.0/24

Example output

Nmap scan report for 192.168.56.1
Host is up.
Nmap scan report for 192.168.56.10
Host is up.

How to read it: Two hosts answered — gateway and your lab VM. Next: targeted -sV on .10 only.

Common mistakes

  • -sn against someone else’s /16
  • Treating “down” as powered-off when ICMP is filtered
nmap port + scripts (lab)— SYN scan + versions + default scripts on common ports. Standard lab reco…

What it does

SYN scan + versions + default scripts on common ports. Standard lab recon pattern — still requires written authorization outside your VMs.

Syntax

nmap -sS -sV -sC -p 22,80,443 target

Important flags / options

  • -sSSYN scan (root/cap)
  • -sTConnect scan (no raw sockets)
  • -sVVersions
  • -sCDefault scripts

Example (lab)

nmap -sT -sV -p 22,80 127.0.0.1

Example output

22/tcp open  ssh     OpenSSH 9.6
80/tcp closed http

How to read it: SSH open locally; HTTP closed — matches earlier nc/ss results.

Common mistakes

  • -A -p- on fragile production
  • Skipping -oA and losing evidence
openssl s_client (TLS)— See certificate chain, protocol, and verify return code without a browse…

What it does

See certificate chain, protocol, and verify return code without a browser. Essential when curl fails with CERT errors.

Syntax

openssl s_client -connect host:443 -servername name</dev/null

Important flags / options

  • -servernameSNI
  • -showcertsFull chain
  • -tls1_2Force version

Example (lab)

echo | openssl s_client -connect 127.0.0.1:8443 -servername lab.local 2>/dev/null | openssl x509 -noout -subject -dates

Example output

subject=CN = lab.local
notBefore=…
notAfter=…

How to read it: Cert CN matches lab.local — if browser still fails, check trust store / intermediate chain.

Common mistakes

  • Ignoring verify error:num= in the full s_client output

Windows (32)

dir— Lists directory contents (cmd).

What it does

Lists directory contents (cmd).

Syntax

dir [path] [options]

Important flags / options

  • /aInclude hidden
  • /sRecursive

Example (lab)

dir /a C:\Users

Example output

…file listing…

How to read it: Windows analogue to ls for quick enumeration.

Common mistakes

  • Assuming PowerShell-only environments
Get-ChildItem— PowerShell directory listing.

What it does

PowerShell directory listing.

Syntax

Get-ChildItem [-Force] [path]

Important flags / options

  • -ForceShow hidden
  • -RecurseWalk tree

Example (lab)

Get-ChildItem -Force $env:USERPROFILE

Example output

…items…

How to read it: Prefer PowerShell on modern Windows SOC/IR work.

Common mistakes

  • Forgetting -Force hides dot-like items
ipconfig— Shows IP configuration.

What it does

Shows IP configuration.

Syntax

ipconfig [/all]

Important flags / options

  • /allFull details
  • /flushdnsClear DNS cache

Example (lab)

ipconfig /all

Example output

IPv4 Address . . : 192.168.1.50

How to read it: Adapter addresses, gateways, DNS servers.

Common mistakes

  • Using only /all screenshots without noting DHCP vs static
netstat (Win)— Shows connections and owning PIDs.

What it does

Shows connections and owning PIDs.

Syntax

netstat -ano

Important flags / options

  • -aAll
  • -nNumeric
  • -oPID

Example (lab)

netstat -ano | findstr LISTENING

Example output

TCP 0.0.0.0:445 … LISTENING 4

How to read it: Map listening ports to PIDs for IR.

Common mistakes

  • Killing PID 4 blindly — often System
Get-Process— Lists running processes in PowerShell.

What it does

Lists running processes in PowerShell.

Syntax

Get-Process [name]

Important flags / options

  • | SortSort by CPU/WS

Example (lab)

Get-Process | Sort-Object CPU -Descending

Example output

…top CPU…

How to read it: Quick process triage before deep EDR.

Common mistakes

  • Stopping critical system processes
Get-WinEvent— Query Windows Event Log.

What it does

Query Windows Event Log.

Syntax

Get-WinEvent -FilterHashtable @{…}

Important flags / options

  • LogNamee.g. Security
  • IdEvent ID

Example (lab)

Get-WinEvent -FilterHashtable @{LogName='Security'; Id=4625} -MaxEvents 20

Example output

…failed logons…

How to read it: Modern replacement for many wevtutil workflows.

Common mistakes

  • Huge unfiltered queries on busy DCs
whoami /groups— Shows current user group memberships.

What it does

Shows current user group memberships.

Syntax

whoami /groups

Important flags / options

  • /privPrivileges
  • /allFull

Example (lab)

whoami /groups

Example output

…BUILTIN\Administrators…

How to read it: Check effective privileges after token changes.

Common mistakes

  • Assuming UI 'admin' equals high integrity token
icacls— View/modify NTFS ACLs.

What it does

View/modify NTFS ACLs.

Syntax

icacls path

Important flags / options

  • /grantAdd ACE
  • /removeRemove

Example (lab)

icacls C:\lab\share

Example output

…NT AUTHORITY\SYSTEM:(F)…

How to read it: Permission review for shares and service paths.

Common mistakes

  • Granting Everyone:F to 'fix' access
sc query— Query Windows services (cmd).

What it does

Query Windows services (cmd).

Syntax

sc query [service]

Example (lab)

sc query wuauserv

Example output

STATE : 4 RUNNING

How to read it: Service state during hardening/IR.

Common mistakes

  • Stopping update services permanently without change control
reg query— Read registry values from cmd.

What it does

Read registry values from cmd.

Syntax

reg query HKLM\…

Example (lab)

reg query HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run

Example output

…autoruns…

How to read it: Persistence checks (pair with Autoruns in labs).

Common mistakes

  • Editing HKLM without backup/change ticket
Get-NetTCPConnection— PowerShell view of TCP connections.

What it does

PowerShell view of TCP connections.

Syntax

Get-NetTCPConnection

Important flags / options

  • -State ListenListeners

Example (lab)

Get-NetTCPConnection -State Listen

Example output

LocalAddress LocalPort State …

How to read it: Find unexpected listening ports.

Common mistakes

  • Running without admin on locked-down hosts
Get-FileHash— Integrity hashing for files.

What it does

Integrity hashing for files.

Syntax

Get-FileHash -Algorithm SHA256 file

Important flags / options

  • SHA256Common algo

Example (lab)

Get-FileHash .\sample.exe -Algorithm SHA256

Example output

Algorithm Hash Path

How to read it: Compare to known-good hashes.

Common mistakes

  • Hashing huge files over slow shares
Get-AuthenticodeSignature— Check Authenticode signature status.

What it does

Check Authenticode signature status.

Syntax

Get-AuthenticodeSignature file.exe

Example (lab)

Get-AuthenticodeSignature .\update.exe

Example output

Status: Valid

How to read it: Detect unsigned or tampered binaries.

Common mistakes

  • Trusting Valid without checking publisher
Select-String— PowerShell grep. Search logs and configs for IOCs without leaving the Wi…

What it does

PowerShell grep. Search logs and configs for IOCs without leaving the Windows admin toolkit.

Syntax

Select-String -Path files -Pattern regex

Important flags / options

  • -PathFiles/glob
  • -PatternRegex
  • -ContextLines around match

Example (lab)

Select-String -Path C:\lab\logs\*.log -Pattern 'Failed password|4625'

Example output

auth.log:12:Failed password for …

How to read it: Matched failure patterns across lab logs — start timeline building from these hits.

Common mistakes

  • Scanning entire C:\ without filters
  • Case-sensitive surprises in regex
Get-LocalUser / Get-LocalGroup— Enumerate local accounts and group membership. Look for unexpected admin…

What it does

Enumerate local accounts and group membership. Look for unexpected admins after a lab compromise exercise.

Syntax

Get-LocalUser ; Get-LocalGroupMember Administrators

Important flags / options

  • Get-LocalUserUsers
  • Get-LocalGroupMemberMembers of a group

Example (lab)

Get-LocalGroupMember Administrators

Example output

ObjectClass Name
---------- ----
User        LAB\alice
User        LAB\backup_admin

How to read it: backup_admin in Administrators deserves explanation in your hardening checklist.

Common mistakes

  • Removing built-in Administrator carelessly
net user / net localgroup— Classic cmd enumeration still seen in malware and older runbooks. Know b…

What it does

Classic cmd enumeration still seen in malware and older runbooks. Know both cmd and PowerShell forms.

Syntax

net user ; net localgroup Administrators

Important flags / options

  • net user nameUser detail
  • net localgroupList groups

Example (lab)

net localgroup Administrators

Example output

Members
---------------
alice
backup_admin

How to read it: Same story as Get-LocalGroupMember — unexpected admin is a finding.

Common mistakes

  • net user evil /add without authorization
schtasks— Lists scheduled tasks — common persistence. Compare to baseline after ma…

What it does

Lists scheduled tasks — common persistence. Compare to baseline after malware labs.

Syntax

schtasks /query /fo LIST /v

Important flags / options

  • /queryList
  • /CreateCreate (admin)
  • /fo LISTReadable format

Example (lab)

schtasks /query /fo LIST /v | findstr /i "TaskName Author Run"

Example output

TaskName: \Lab\Updater
Author: LAB\alice
Run: powershell -enc …

How to read it: Encoded PowerShell in a task is suspicious — decode in a sandbox.

Common mistakes

  • Disabling vendor update tasks permanently without change control
Get-MpComputerStatus— Defender status: real-time protection, signatures age, last scan. Baseli…

What it does

Defender status: real-time protection, signatures age, last scan. Baseline for endpoint hardening labs.

Syntax

Get-MpComputerStatus

Important flags / options

  • AMServiceEnabledService on?
  • AntivirusSignatureLastUpdatedDefs freshness

Example (lab)

Get-MpComputerStatus | Select AMServiceEnabled, RealTimeProtectionEnabled, AntivirusSignatureLastUpdated

Example output

AMServiceEnabled : True
RealTimeProtectionEnabled : True
AntivirusSignatureLastUpdated : 2024-06-01 …

How to read it: Protection is on and signatures are recent — good lab baseline.

Common mistakes

  • Disabling Defender 'to make the lab easier' on a host you still browse with
certutil -hashfile— Built-in hashing without installing tools. Compare to vendor checksums b…

What it does

Built-in hashing without installing tools. Compare to vendor checksums before running installers.

Syntax

certutil -hashfile file SHA256

Important flags / options

  • SHA256Algorithm
  • MD5Legacy (avoid for security)

Example (lab)

certutil -hashfile .\installer.msi SHA256

Example output

SHA256 hash of installer.msi:
AB12CD…

How to read it: Match this to the vendor’s published hash before install.

Common mistakes

  • Trusting hashes posted on the same shady download page
Test-NetConnection— PowerShell connectivity test (ICMP + optional TCP). Replaces many ad-hoc…

What it does

PowerShell connectivity test (ICMP + optional TCP). Replaces many ad-hoc telnet checks.

Syntax

Test-NetConnection host -Port port

Important flags / options

  • -PortTCP port
  • -TraceRoutePath
  • -InformationLevel DetailedMore fields

Example (lab)

Test-NetConnection 127.0.0.1 -Port 445

Example output

TcpTestSucceeded : True

How to read it: SMB port open locally — expected on many Windows labs; lock down on exposed hosts.

Common mistakes

  • Interpreting ICMP failure as 'host down' when only ICMP is blocked
ping (Windows)— Windows ICMP reachability test. Same idea as Linux ping: prove L3 path a…

What it does

Windows ICMP reachability test. Same idea as Linux ping: prove L3 path and rough latency. Use before blaming the application when “the site is down.”

Syntax

ping [-n count] [-t] host

Important flags / options

  • -n NSend N echoes then stop
  • -tPing until Ctrl+C
  • -4 / -6Force IPv4 / IPv6

Example (lab)

ping -n 4 192.168.56.10

Example output

Reply from 192.168.56.10: bytes=32 time=1ms TTL=64
…
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss)

How to read it: 0% loss and ~1 ms RTT → lab VM is up on the Host-Only network. Next step if apps fail: check port with Test-NetConnection.

Common mistakes

  • Assuming timeout means host is powered off (firewall may drop ICMP)
  • Leaving ping -t running forever on shared jump hosts
tracert— Windows traceroute — lists hops to a destination. Use when latency is hi…

What it does

Windows traceroute — lists hops to a destination. Use when latency is high or a path suddenly changes after VPN/firewall changes.

Syntax

tracert [-d] host

Important flags / options

  • -dDo not resolve hostnames
  • -h NMax hops
  • -4 / -6Address family

Example (lab)

tracert -d 1.1.1.1

Example output

1  1 ms  1 ms  1 ms  192.168.1.1
2  8 ms  7 ms  8 ms  10.0.0.1
3  …  1.1.1.1

How to read it: Hop 1 is your router; later hops are ISP/core. Request timed out on a hop often means ICMP rate-limit, not a hard failure.

Common mistakes

  • Treating every * as a broken router
  • Running endless traces against third-party infrastructure
pathping— Combines traceroute with per-hop statistics (Windows). Slower than trace…

What it does

Combines traceroute with per-hop statistics (Windows). Slower than tracert but better for spotting lossy hops on a path you are authorized to test.

Syntax

pathping [-n] host

Important flags / options

  • -nNo DNS
  • -q NQueries per hop

Example (lab)

pathping -n 192.168.56.1

Example output

Computing statistics for 25 seconds…
Hop  RTT  Lost/Sent = Pct  Address
0           0/100 = 0%     your-pc
1    1ms    0/100 = 0%     192.168.56.1

How to read it: Percent loss near hop 1 points at the LAN/gateway; loss only at the last hop often means the target rate-limits ICMP.

Common mistakes

  • Running pathping on every ticket (it is slow)
  • Misreading mid-path * as packet loss
hostname (Windows)— Shows computer name; PowerShell can show address list. Useful when RDP t…

What it does

Shows computer name; PowerShell can show address list. Useful when RDP targets the wrong name after a clone.

Syntax

hostname ; [System.Net.Dns]::GetHostByName(($env:computerName))

Example (lab)

hostname

Example output

LAB-WIN11

How to read it: NetBIOS/computer name is LAB-WIN11 — compare with DNS A record in your lab zone.

Common mistakes

  • Renaming domain-joined machines outside the proper domain process
nslookup (Windows)— Built-in Windows DNS query. Use to verify which resolver the OS is using…

What it does

Built-in Windows DNS query. Use to verify which resolver the OS is using after VPN connect.

Syntax

nslookup name [server]

Example (lab)

nslookup lab-web.internal 192.168.56.2

Example output

Server:  UnKnown
Address:  192.168.56.2

Name:    lab-web.internal
Address:  192.168.56.10

How to read it: Resolver 192.168.56.2 returned 192.168.56.10 — matches your Host-Only lab DNS.

Common mistakes

  • Stopping at nslookup when dig is available for MX/TXT/CAA
  • Ignoring which Server: answered
Get-DnsClientCache— View/clear the Windows DNS client cache when a record changed but the PC…

What it does

View/clear the Windows DNS client cache when a record changed but the PC still hits the old IP.

Syntax

Get-DnsClientCache ; Clear-DnsClientCache

Important flags / options

  • Clear-DnsClientCacheFlush
  • ipconfig /flushdnsClassic equivalent

Example (lab)

Get-DnsClientCache | Where-Object Entry -like '*lab*' | Format-Table -AutoSize

Example output

Entry            RecordType Section TimeToLive Data
lab-web.internal A          Answer  42         192.168.56.10

How to read it: Cached A record still valid — if the server IP moved, flush and resolve again.

Common mistakes

  • Flushing DNS as a cargo-cult fix without checking authoritative dig
Test-NetConnection (detailed)— PowerShell connectivity Swiss army knife: ping + TCP + optional tracerou…

What it does

PowerShell connectivity Swiss army knife: ping + TCP + optional traceroute. Prefer this over telnet on modern Windows.

Syntax

Test-NetConnection host -Port port -InformationLevel Detailed

Important flags / options

  • -PortTCP port
  • -TraceRouteShow path
  • -InformationLevel DetailedFull object

Example (lab)

Test-NetConnection 192.168.56.10 -Port 22 -InformationLevel Detailed

Example output

ComputerName        : 192.168.56.10
RemotePort          : 22
TcpTestSucceeded    : True
PingSucceeded       : True

How to read it: Both ICMP and TCP/22 work — SSH should be reachable; if ssh.exe still fails, check keys/algorithms next.

Common mistakes

  • Assuming PingSucceeded false means host is offline
arp -a (Windows)— Windows ARP cache dump. Compare MAC vendors when hunting duplicate IPs o…

What it does

Windows ARP cache dump. Compare MAC vendors when hunting duplicate IPs or lab gateway changes.

Syntax

arp -a

Important flags / options

  • -aDisplay
  • -dDelete entry

Example (lab)

arp -a | findstr 192.168.56

Example output

192.168.56.1    0a-00-27-00-00-01    dynamic
192.168.56.10   08-00-27-aa-bb-cc    dynamic

How to read it: Gateway and lab VM MACs look like VirtualBox OUIs — expected in a Host-Only lab.

Common mistakes

  • Static ARP without change tickets
  • Trusting ARP on public Wi‑Fi
route print— Windows routing table. When VPN splits traffic wrong, this shows which g…

What it does

Windows routing table. When VPN splits traffic wrong, this shows which gateway owns 0.0.0.0 and specific prefixes.

Syntax

route print

Important flags / options

  • -4 / -6Address family
  • add/deleteModify (admin)

Example (lab)

route print -4 | findstr /i "0.0.0.0 192.168.56"

Example output

0.0.0.0  0.0.0.0  192.168.1.1  …
192.168.56.0  255.255.255.0  On-link  192.168.56.50 …

How to read it: Default via home router; lab /24 is on-link on the Host-Only adapter — good split.

Common mistakes

  • route delete 0.0.0.0 remotely without console access
Get-NetRoute— PowerShell routing view — filterable objects instead of raw route print …

What it does

PowerShell routing view — filterable objects instead of raw route print text.

Syntax

Get-NetRoute -AddressFamily IPv4 | Format-Table -AutoSize

Important flags / options

  • -DestinationPrefixFilter
  • -InterfaceAliasPer NIC

Example (lab)

Get-NetRoute -DestinationPrefix '0.0.0.0/0'

Example output

ifIndex DestinationPrefix NextHop     RouteMetric
12      0.0.0.0/0          192.168.1.1 25

How to read it: Default route metric 25 via 192.168.1.1 — if two defaults exist, lower metric wins.

Common mistakes

  • Adding persistent routes that survive reboot without documentation
Get-NetFirewallRule— Inspect enabled Windows Firewall rules when a lab port is blocked locall…

What it does

Inspect enabled Windows Firewall rules when a lab port is blocked locally but ss/netstat shows LISTENING.

Syntax

Get-NetFirewallRule -Enabled True | …

Important flags / options

  • -DisplayNameFilter by name
  • -Direction InboundInbound only
  • Get-NetFirewallPortFilterPort details

Example (lab)

Get-NetFirewallRule -Enabled True -Direction Inbound | Get-NetFirewallPortFilter | Where-Object LocalPort -eq 3389

Example output

Protocol LocalPort
TCP      3389

How to read it: An inbound rule references 3389 — confirm Action Allow and RemoteAddress scope next.

Common mistakes

  • Disabling Windows Firewall entirely on laptops that leave the lab
Resolve-DnsName— PowerShell DNS lookups with typed records — cleaner scripting than parsi…

What it does

PowerShell DNS lookups with typed records — cleaner scripting than parsing nslookup text.

Syntax

Resolve-DnsName name -Type A

Important flags / options

  • -TypeA/AAAA/MX/TXT/CNAME
  • -ServerResolver IP
  • -DnsOnlySkip LLMNR/NetBIOS

Example (lab)

Resolve-DnsName lab-web.internal -Type A -Server 192.168.56.2

Example output

Name       Type TTL Section IPAddress
lab-web…   A    30  Answer  192.168.56.10

How to read it: Lab DNS returns the expected A record from your private resolver.

Common mistakes

  • Forgetting -Server and hitting public DNS for internal names

DNS (7)

host— Simple DNS lookup utility.

What it does

Simple DNS lookup utility.

Syntax

host [-t type] name

Important flags / options

  • -t TXTTXT records

Example (lab)

host -t MX example.com

Example output

example.com mail is handled by 10 mail.example.com

How to read it: Quick MX checks for email security.

Common mistakes

  • Assuming host does full DNSSEC validation display
whois— Registration metadata for domains (OSINT).

What it does

Registration metadata for domains (OSINT).

Syntax

whois domain

Example (lab)

whois example.com

Example output

Registrar: … Creation Date: …

How to read it: Useful for phishing domain age/reputation.

Common mistakes

  • Automating whois without rate limits
resolvectl— systemd-resolved DNS query on modern Linux.

What it does

systemd-resolved DNS query on modern Linux.

Syntax

resolvectl query name

Important flags / options

  • statusResolver state

Example (lab)

resolvectl query internal.corp

Example output

internal.corp: 10.0.0.5

How to read it: Debug split-horizon DNS in labs.

Common mistakes

  • Confusing with legacy resolv.conf only
dig +trace— Follows delegation from root to authoritative servers. Teaches how DNS h…

What it does

Follows delegation from root to authoritative servers. Teaches how DNS hierarchy works and where spoofing/cache issues can appear.

Syntax

dig +trace name

Important flags / options

  • +traceFull path
  • +dnssecShow DNSSEC bits

Example (lab)

dig +trace example.com

Example output

. …
com. …
example.com. … A 93.184.215.14

How to read it: Each section is a referral until the final A record — compare with a normal dig for caching differences.

Common mistakes

  • Assuming +trace equals DNSSEC validation
dig +short A/AAAA— Quick dual-stack checks. Many “works on my phone / fails on laptop” bugs…

What it does

Quick dual-stack checks. Many “works on my phone / fails on laptop” bugs are A vs AAAA differences.

Syntax

dig +short name A ; dig +short name AAAA

Important flags / options

  • +shortOne-line answers
  • @resolverQuery a specific server

Example (lab)

dig +short example.com A; dig +short example.com AAAA

Example output

93.184.215.14
2606:2800:220:1:248:1893:25c8:1946

How to read it: Both A and AAAA exist — a v6-only path failure would still leave v4 working.

Common mistakes

  • Forgetting +short and drowning in dig verbosity during demos
dig TXT / SPF / DMARC— Pull TXT records used in email authentication (SPF, DMARC) and domain ve…

What it does

Pull TXT records used in email authentication (SPF, DMARC) and domain verification. Core for phishing-domain and mail-hardening labs.

Syntax

dig TXT name +short

Important flags / options

  • TXTText records
  • _dmarc.domainDMARC policy name

Example (lab)

dig TXT example.com +short; dig TXT _dmarc.example.com +short

Example output

"v=spf1 -all"
"v=DMARC1; p=reject; …"

How to read it: SPF -all and DMARC reject are strict — good for a domain that should not send mail.

Common mistakes

  • Editing production SPF without a staged rollout
  • Assuming dig TXT shows DKIM selectors automatically
nslookup set type— Interactive nslookup record-type switching when dig is missing (common o…

What it does

Interactive nslookup record-type switching when dig is missing (common on locked Windows images).

Syntax

nslookup → set type=MX

Important flags / options

  • set type=MXMail exchangers
  • set type=NSName servers
  • server IPChange resolver

Example (lab)

nslookup
> set type=MX
> example.com

Example output

example.com MX preference = 10, mail exchanger = mail.example.com

How to read it: Mail flows to mail.example.com at preference 10 — compare with dig MX +short.

Common mistakes

  • Leaving interactive nslookup open in shared screen sessions

Cloud (8)

aws iam— Manage AWS IAM (authorized accounts only).

What it does

Manage AWS IAM (authorized accounts only).

Syntax

aws iam <command>

Important flags / options

  • list-usersUsers
  • get-account-authorization-detailsPolicy dump

Example (lab)

aws iam list-users --max-items 5

Example output

Users: [ … ]

How to read it: Inventory identities in sandbox.

Common mistakes

  • Running on production without change control
aws sts— Show current AWS credential identity.

What it does

Show current AWS credential identity.

Syntax

aws sts get-caller-identity

Example (lab)

aws sts get-caller-identity

Example output

Account: 123456789012 Arn: …

How to read it: Confirm which principal you are using.

Common mistakes

  • Using root access keys
aws s3— List S3 buckets/objects (read-only recon).

What it does

List S3 buckets/objects (read-only recon).

Syntax

aws s3 ls s3://bucket

Important flags / options

  • lsList
  • api get-bucket-aclACL review

Example (lab)

aws s3 ls

Example output

2024-01-01 12:00:00 my-bucket

How to read it: Find exposed buckets in your account.

Common mistakes

  • Modifying buckets without backup
az account— Show active Azure subscription.

What it does

Show active Azure subscription.

Syntax

az account show

Example (lab)

az account show

Example output

name: LabSubscription …

How to read it: Confirm subscription context.

Common mistakes

  • Wrong subscription selected
az role assignment— List Azure RBAC assignments.

What it does

List Azure RBAC assignments.

Syntax

az role assignment list

Example (lab)

az role assignment list --assignee user@corp.com

Example output

Role assignments …

How to read it: Audit excessive RBAC.

Common mistakes

  • Assigning Owner at root scope
gcloud iam— View GCP IAM bindings.

What it does

View GCP IAM bindings.

Syntax

gcloud projects get-iam-policy PROJECT

Example (lab)

gcloud projects get-iam-policy my-lab-proj

Example output

bindings: …

How to read it: Find allUsers/allAuthenticatedUsers.

Common mistakes

  • Granting roles/owner casually
aws ec2 describe-instances— Inventory EC2 in an account you control. Look for public IPs, missing ta…

What it does

Inventory EC2 in an account you control. Look for public IPs, missing tags, and overly open security groups.

Syntax

aws ec2 describe-instances [--filters …]

Important flags / options

  • --queryJMSE projection
  • --filtersNarrow results

Example (lab)

aws ec2 describe-instances --query 'Reservations[].Instances[].{Id:InstanceId,IP:PublicIpAddress,SG:SecurityGroups}' --output table

Example output

Id               IP             SG
i-0abc…          203.0.113.10   launch-wizard-1

How to read it: Public IP with default wizard SG is a classic lab misconfig to fix.

Common mistakes

  • Running broad describe in production from laptops without MFA session
aws route53 list-resource-record-sets (lab)— Inventory DNS records in a hosted zone you control — pair with dig from …

What it does

Inventory DNS records in a hosted zone you control — pair with dig from the public Internet to verify propagation.

Syntax

aws route53 list-resource-record-sets --hosted-zone-id ZONE

Important flags / options

  • --hosted-zone-idZone id
  • --queryJMSE filter

Example (lab)

aws route53 list-resource-record-sets --hosted-zone-id Z3LABEXAMPLE --query "ResourceRecordSets[?Type=='A']" --output table

Example output

Name              Type TTL  ResourceRecords
lab.example.com.  A    60   203.0.113.10

How to read it: Authoritative A record is 203.0.113.10 — dig @8.8.8.8 should match after TTL.

Common mistakes

  • Changing prod records without change window
  • Leaving TTL=60 forever as a cost/perf tradeoff unnoticed

Containers (9)

docker inspect— JSON metadata about a container.

What it does

JSON metadata about a container.

Syntax

docker inspect container

Example (lab)

docker inspect lab_web_1

Example output

Config, Mounts, NetworkSettings …

How to read it: Find privileged mode / mounted sockets.

Common mistakes

  • Inspecting production without read-only role
docker scout— Image vulnerability quick view (Docker Scout).

What it does

Image vulnerability quick view (Docker Scout).

Syntax

docker scout cves image:tag

Example (lab)

docker scout cves myapp:lab

Example output

CVE list …

How to read it: Pre-deploy image scan.

Common mistakes

  • Ignoring unfixed base image CVEs
kubectl get— List Kubernetes resources.

What it does

List Kubernetes resources.

Syntax

kubectl get pods -A

Important flags / options

  • -AAll namespaces
  • -o wideExtra columns

Example (lab)

kubectl get pods -A

Example output

NAMESPACE NAME READY STATUS …

How to read it: Inventory workloads.

Common mistakes

  • kubectl get secrets -o yaml in shared terminals
kubectl describe— Detailed pod events and spec.

What it does

Detailed pod events and spec.

Syntax

kubectl describe pod name

Example (lab)

kubectl describe pod web-7f8c…

Example output

Events: … Limits: …

How to read it: Debug crashloops and misconfig.

Common mistakes

  • Describing in prod without ticket
kubectl auth can-i— Check RBAC permissions for current user.

What it does

Check RBAC permissions for current user.

Syntax

kubectl auth can-i --list

Example (lab)

kubectl auth can-i create secrets --namespace prod

Example output

yes/no

How to read it: Verify least privilege.

Common mistakes

  • Assuming cluster-admin is normal
kubectl logs— Fetch container stdout/stderr. First stop for CrashLoopBackOff and app e…

What it does

Fetch container stdout/stderr. First stop for CrashLoopBackOff and app errors in K8s labs.

Syntax

kubectl logs pod [-c container] [--previous]

Important flags / options

  • -fFollow
  • --previousLast crashed instance
  • -n nsNamespace

Example (lab)

kubectl logs deploy/web -n lab --tail=50

Example output

ERROR: connection refused to db:5432

How to read it: App cannot reach the database Service — check NetworkPolicy and Service selectors next.

Common mistakes

  • kubectl logs on prod without ticket
  • Forgetting --previous when the current container just started
trivy image— Scans container images for OS/app CVEs. Run in CI before pushing lab ima…

What it does

Scans container images for OS/app CVEs. Run in CI before pushing lab images to a registry.

Syntax

trivy image image:tag

Important flags / options

  • --severity HIGH,CRITICALFilter
  • --exit-code 1Fail build

Example (lab)

trivy image myapp:lab --severity HIGH,CRITICAL

Example output

Total: 3 (HIGH: 2, CRITICAL: 1)

How to read it: Rebuild from a patched base image before 'shipping' the lab demo.

Common mistakes

  • Ignoring base image CVEs forever
  • Scanning only latest tag while prod runs old digests
kubectl port-forward— Tunnel a cluster Service to localhost for debugging when Ingress is not …

What it does

Tunnel a cluster Service to localhost for debugging when Ingress is not ready. Lab/cluster you admin only.

Syntax

kubectl port-forward svc/name local:remote -n ns

Important flags / options

  • svc/nameService
  • 8080:80Local:remote ports
  • -nNamespace

Example (lab)

kubectl port-forward svc/web 8080:80 -n lab

Example output

Forwarding from 127.0.0.1:8080 -> 80

How to read it: Browse http://127.0.0.1:8080 while the forward runs — stop with Ctrl+C when done.

Common mistakes

  • port-forward in prod as a permanent access method
  • Exposing forwards on 0.0.0.0 unintentionally
docker run --rm curl— Reach an endpoint from inside the container network namespace when host …

What it does

Reach an endpoint from inside the container network namespace when host curl works but the app container cannot — classic Docker DNS/bridge issues.

Syntax

docker run --rm curlimages/curl:latest URL

Important flags / options

  • --rmDelete after run
  • --networkJoin a compose network

Example (lab)

docker run --rm --network lab_default curlimages/curl:latest -sI http://web:80/

Example output

HTTP/1.1 200 OK

How to read it: Service name `web` resolves on the compose network — if this fails, check compose service names and network attachment.

Common mistakes

  • Pulling images in air-gapped labs without a mirror
  • Using latest tags in production debug one-offs without noting digest