all commands

Find the Linux command that matches the problem.

Browse 285 safety-rated command fixes. Start with read-only checks when you are unsure, and use caution labels as a reason to slow down before copying.

285 commands

Command library

Web Server Rescue safe
Read-only Command replay Cert practice

Your Site Is Not Down. DNS Might Be Lying.

The browser said the site was gone. The server was answering fine.

curl --resolve example.com:443:203.0.113.10 https://example.com/
Linux Survival Basics safe
Read-only Command replay Cert practice

Find the Files Eating Your Disk

The disk was full, but guessing at folders was the slow part.

find /var -type f -printf '%s %p\n' | sort -nr | head -20
Dangerous Commands caution
Needs caution Command replay Cert practice

Run Rsync Without Deleting Your Backup

One rsync flag can save you. Another can erase the wrong side.

rsync -avhn --delete ./source/ ./backup/
Linux Survival Basics safe
Read-only Command replay Cert practice

Watch Logs Without Opening the Whole File

The app was failing now. Opening a giant log file was the wrong move.

tail -n 80 -f /var/log/nginx/error.log
Linux Survival Basics safe
Read-only Command replay Cert practice

Find Errors Before Reading Every Log Line

The error was in the log. The problem was finding it without reading noise.

grep -iE 'error|failed|denied|timeout' /var/log/nginx/error.log | tail -40
Web Server Rescue safe
Read-only Command replay Cert practice

Check What Is Actually Listening

The app was running. The port was not listening.

ss -tulpn | grep ':80\|:443'
Dangerous Commands safe
Read-only Command replay Cert practice

Inspect Permissions Before Changing Them

The permission fix was easy. Knowing what not to chmod was the hard part.

namei -l /var/www/example/index.html
Linux Survival Basics safe
Read-only Command replay Cert practice

Find the Exact Log Line Before You Scroll

The error was there. The useful part was knowing exactly where it was.

grep -inE 'error|failed|denied|timeout' /var/log/nginx/error.log
Linux Survival Basics safe
Read-only Command replay Cert practice

Find Which Folder Is Filling the Disk

The disk was full. The fastest clue was the folder, not the file.

du -sh /var/* 2>/dev/null | sort -h
Linux Survival Basics safe
Read-only Command replay Cert practice

Show Only Recent Errors

The log had old failures too. I only cared about the newest ones.

grep -iE 'error|failed|denied|timeout' /var/log/nginx/error.log | tail -10
Dangerous Commands caution
Needs caution Command replay Cert practice

Preview What Rsync Would Delete

`rsync --delete` is useful. It is also how people erase the wrong side.

rsync -avhn --delete ./source/ ./backup/ | grep '^deleting'
Linux Survival Basics safe
Read-only Command replay Cert practice

Check Owner and Mode in One Line

The file existed. The owner and mode explained why it still failed.

stat -c '%A %U:%G %n' /var/www/example/index.html
Linux Survival Basics safe
Read-only Command replay Cert practice

Find the Processes Using Memory

The server felt slow. Memory pressure was the first thing to rule out.

ps -eo pid,comm,%mem,%cpu --sort=-%mem | head
Linux Survival Basics safe
Read-only Command replay Cert practice

Show Big Files in Human Units

Byte counts are precise. Human units are faster under pressure.

find /var -type f -printf '%s %p\n' | sort -nr | head -10 | awk '{printf "%.1f MB %s\n", $1/1024/1024, $2}'
Apple Terminal safe
Read-only Command replay Cert practice

Find What Is Using a Local Dev Port

Your dev server says port 3000 is busy. Ask macOS who is holding it.

lsof -nP -iTCP:3000 -sTCP:LISTEN
Apple Terminal caution
Needs caution Command replay Cert practice

Stop the Process Blocking a Dev Port

Free a stuck dev port without hunting through Activity Monitor.

lsof -ti tcp:3000 | xargs kill
Apple Terminal safe
Read-only Command replay Cert practice

Show Your PATH One Entry Per Line

Wrong Node, Python, or FFmpeg? Start by reading your PATH clearly.

echo "$PATH" | tr ':' '\n' | nl -ba
Apple Terminal safe
Read-only Command replay Cert practice

See Exactly Which Command macOS Will Run

Before blaming npm, Python, or Git, check the binary your shell actually found.

command -v node && node -v
Apple Terminal safe
Read-only Command replay Cert practice

Find Large Files Inside a Project

Before committing, check whether a huge video, build artifact, or export slipped into your repo.

find . -type f -size +100M -print
Apple Terminal safe
Read-only Command replay Cert practice

Find Which Folder Is Eating Disk Space

When your Mac is full, start with the biggest folders in the current directory.

du -sh ./* 2>/dev/null | sort -h
Apple Terminal caution
Needs caution Command replay Cert practice

Flush macOS DNS Cache

Changed DNS but your Mac still visits the old place? Flush the resolver cache.

sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
Apple Terminal safe
Read-only Command replay Cert practice

Watch a Log or Build File Update

Need to see whether a file is still changing? Let tail follow it live.

tail -f ./app.log
Apple Terminal safe
Read-only Command replay Cert practice

Search a Log for Errors With Context

A wall of logs is useless until you pull the error and the lines around it.

grep -n -C 2 'ERROR' ./app.log
Apple Terminal safe
Read-only Command replay Cert practice

Check a URL Without Downloading the Page

Before opening a broken page in five browsers, ask the server for headers.

curl -I https://example.com
Hosting Operations safe
Read-only Command replay Cert practice

List Newest Source Files Before Backup

Before trusting a backup, know which files changed most recently.

find source -type f -printf '%TY-%Tm-%Td %TH:%TM %p\n' | sort
Hosting Operations safe
Read-only Command replay Cert practice

Create a SHA256 Checksum Manifest

A file list says what exists; checksums say whether bytes match.

sha256sum source/app/config.yml source/content/index.md source/content/about.md source/assets/logo.svg
Hosting Operations safe
Read-only Command replay Cert practice

Verify a SHA256 Checksum Manifest

A checksum file is only useful if you actually verify it.

sha256sum -c checksums.sha256
Hosting Operations safe
Read-only Command replay Cert practice

Compare Source and Backup File Lists

A backup can be missing files and still look plausible at a glance.

comm -3 <(find source -type f | sed 's#^source/##' | sort) <(find backup -type f | sed 's#^backup/##' | sort)
Hosting Operations safe
Read-only Command replay Cert practice

Preview Backup Drift with rsync

Rsync can tell you what would change before it changes anything.

rsync -ain --delete source/ backup/
Hosting Operations safe
Read-only Command replay Cert practice

Find Empty Files in a Backup

Zero-byte files can be normal, or they can be failed writes.

find backup -type f -size 0 -print
Hosting Operations safe
Read-only Command replay Cert practice

List Largest Files in a Backup

Large backup files are where storage surprises usually start.

find backup -type f -printf '%s %p\n' | sort -nr | head
Linux Survival Basics safe
Read-only Command replay Cert practice

List Contents of a Backup Tarball

You can inspect an archive without extracting it.

tar -tf archives/site-backup.tar | sort | head
Linux Survival Basics safe
Read-only Command replay Cert practice

Count Source Files by Extension

A quick extension count can show whether expected content made it into the source tree.

find source -type f -printf '%f\n' | sed -n 's/.*\.//p' | sort | uniq -c | sort -nr
Hosting Operations safe
Read-only Command replay Cert practice

Find Files Newer Than a Backup Snapshot

Files newer than the last snapshot are the ones most likely missing from it.

find source -type f -newer backup/.snapshot -print | sort
Hosting Operations safe
Read-only Command replay Cert practice

List Restore Points Before a Drill

A restore drill starts by proving which backups actually exist.

cd restore-dr && find backups -maxdepth 2 -type f -name MANIFEST.txt -printf '%TY-%Tm-%Td %TH:%TM %h\n' | sort -r
Hosting Operations safe
Read-only Command replay Cert practice

Read the Backup Manifest

The manifest should say what backup you are about to trust.

cd restore-dr && cat backups/2026-06-25/MANIFEST.txt
Hosting Operations safe
Read-only Command replay Cert practice

List Archive Contents Before Extracting

You can inspect a tar backup before it writes a single file.

cd restore-dr && tar -tf backups/2026-06-25/site.tar | sed 's#^./##' | sort
Hosting Operations safe
Read-only Command replay Cert practice

Find Missing Files in an Old Backup

The fastest failed restore drill is the one that finds missing critical files early.

cd restore-dr && tar -tf backups/2026-06-24/site.tar | sed 's#^./##' | sort | comm -23 required-files.txt -
Hosting Operations caution
Needs caution Command replay Cert practice

Extract a Backup Into a Restore Sandbox

A restore drill should write to a sandbox, not production.

cd restore-dr && rm -rf restore-sandbox/full && mkdir -p restore-sandbox/full && tar -xf backups/2026-06-25/site.tar -C restore-sandbox/full
Hosting Operations caution
Needs caution Command replay Cert practice

Verify Restored File Checksums

A restore is not validated until the bytes match.

cd restore-dr && rm -rf restore-sandbox/full && mkdir -p restore-sandbox/full && tar -xf backups/2026-06-25/site.tar -C restore-sandbox/full && (cd restore-sandbox/full && sha256sum -c CHECKSUMS.sha256)
Hosting Operations caution
Needs caution Command replay Cert practice

Diff Restored Config Against Expected

A restored config can exist and still be the wrong config.

cd restore-dr && rm -rf restore-sandbox/full && mkdir -p restore-sandbox/full && tar -xf backups/2026-06-25/site.tar -C restore-sandbox/full && diff -u expected/app/config.yml restore-sandbox/full/app/config.yml
Hosting Operations caution
Needs caution Command replay Cert practice

Check Required Files After Restore

A successful extraction still needs a required-file check.

cd restore-dr && rm -rf restore-sandbox/full && mkdir -p restore-sandbox/full && tar -xf backups/2026-06-25/site.tar -C restore-sandbox/full && find restore-sandbox/full -type f | sed 's#^restore-sandbox/full/##' | sort | comm -23 required-files.txt -
Hosting Operations safe
Read-only Command replay Cert practice

Review Critical File Modes in the Archive

Permissions are part of the restore, not decoration.

cd restore-dr && tar -tvf backups/2026-06-25/site.tar | awk '/secrets.env|deploy.sh/ {print $1, $6}'
Hosting Operations safe
Read-only Command replay Cert practice

Read the Restore Drill Validation Report

A restore drill that leaves no evidence is hard to trust later.

cd restore-dr && grep -E 'status=|rpo_minutes=|rto_seconds=|checksum=|file_count=' reports/restore-dr-2026-06-25.txt
Hosting Operations safe
Read-only Command replay Cert practice

Find the Newest Build Logs First

The failing file is usually one of the newest artifacts.

find artifacts logs -type f \( -name '*.log' -o -name '*.txt' \) -printf '%TY-%Tm-%Td %TH:%TM %p\n' | sort -r | head
Hosting Operations safe
Read-only Command replay Cert practice

Scan Every CI Log for Error Lines

One grep pass can turn a log pile into a failure list.

grep -RInE 'error|failed|failure|exception|traceback' artifacts logs | head -50
Hosting Operations safe
Read-only Command replay Cert practice

Show Context Around the First Error

The line before the error often explains the error.

grep -RInC 3 -m 1 'ERROR' artifacts logs
Hosting Operations safe
Read-only Command replay Cert practice

List Failed Tests from JUnit XML

The XML report already knows which tests failed.

grep -RIn '<failure\|<error' artifacts/test/*.xml
Hosting Operations safe
Read-only Command replay Cert practice

Summarize Test Counts from Reports

Before debugging a test failure, measure the blast radius.

grep -RhoE 'tests="[0-9]+"|failures="[0-9]+"|errors="[0-9]+"|skipped="[0-9]+"' artifacts/test/*.xml | sort | uniq -c
Hosting Operations safe
Read-only Command replay Cert practice

Find Coverage Regression Lines

Coverage failures usually say the threshold out loud.

grep -RInE 'coverage|threshold|minimum|below' artifacts logs
Hosting Operations safe
Read-only Command replay Cert practice

Find the Largest CI Artifacts

A bloated artifact can explain a slow or failed pipeline.

find artifacts -type f -printf '%s %p\n' | sort -nr | head -10
Hosting Operations safe
Read-only Command replay Cert practice

Check Whether Expected Build Outputs Exist

The deploy failed because the build never produced the file.

find artifacts/dist -maxdepth 2 -type f | sort
Hosting Operations safe
Read-only Command replay Cert practice

Detect Secret Leak Markers in Artifacts

Artifacts are public more often than you think.

grep -RInE 'AWS_ACCESS_KEY|SECRET|TOKEN|PRIVATE KEY|PASSWORD' artifacts logs | head -50
Hosting Operations safe
Read-only Command replay Cert practice

Find Tests That Passed After Rerun

A green retry can still hide a flaky test.

grep -RInE 'rerun|retry|flaky|passed on retry|failed attempt' artifacts logs
Hosting Operations safe
Read-only Command replay Cert practice

Show Active PostgreSQL Connections

The database was not down. It was full.

psql -X -A -F '|' -c "select pid,usename,datname,state,client_addr from pg_stat_activity order by state, pid;"
Hosting Operations safe
Read-only Command replay Cert practice

Find Long-Running PostgreSQL Queries

One query can make the whole app look broken.

psql -X -c "select pid, now() - query_start as age, state, left(query, 80) as query from pg_stat_activity where query_start is not null order by age desc limit 10;"
Hosting Operations safe
Read-only Command replay Cert practice

Check PostgreSQL Lock Waits

The outage was a queue, not a crash.

psql -X -c "select pid, wait_event_type, wait_event, state, left(query, 80) as query from pg_stat_activity where wait_event_type is not null order by pid;"
Hosting Operations safe
Read-only Command replay Cert practice

Show PostgreSQL Database Sizes

Disk pressure starts with knowing what grew.

psql -X -c "select datname, pg_size_pretty(pg_database_size(datname)) as size from pg_database order by pg_database_size(datname) desc;"
Hosting Operations safe
Read-only Command replay Cert practice

Check Whether MySQL Responds

The port was open. MySQL still had to answer.

mysqladmin ping -h 127.0.0.1 -P 3306
Hosting Operations safe
Read-only Command replay Cert practice

Show Active MySQL Sessions

The app was waiting behind busy sessions.

mysql -e "show full processlist;"
Hosting Operations safe
Read-only Command replay Cert practice

Find Long-Running MySQL Queries

One old query explained the whole slowdown.

mysql -e "select id,user,host,db,command,time,state,left(info,80) as info from information_schema.processlist where command <> 'Sleep' order by time desc limit 10;"
Hosting Operations safe
Read-only Command replay Cert practice

Show MySQL Database Sizes

The storage alert needed a database name.

mysql -e "select table_schema, round(sum(data_length + index_length)/1024/1024, 1) as mb from information_schema.tables group by table_schema order by mb desc;"
Cybersecurity Triage safe
Read-only Command replay Cert practice

Check Whether Databases Listen Publicly

The fastest database security check is the listening address.

ss -ltnp | awk '$4 ~ /:(5432|3306)$/ {print}'
Linux Survival Basics safe
Read-only Command replay Cert practice

Fingerprint a Debian or Ubuntu Host

Before package triage, prove what OS family and release you are actually on.

. /etc/os-release && printf '%s %s %s\n' "$ID" "$VERSION_ID" "$VERSION_CODENAME"
Linux Survival Basics safe
Read-only Command replay Cert practice

Compare Kernel and Distro Versions

The distro version and kernel version answer different questions.

printf 'kernel=%s arch=%s distro=%s\n' "$(uname -r)" "$(uname -m)" "$(lsb_release -ds)"
Linux Survival Basics safe
Read-only Command replay Cert practice

List Installed Package Versions

A package inventory beats memory when a server is drifting.

dpkg-query -W -f='${Package}\t${Version}\t${Architecture}\n' | sort
Linux Survival Basics safe
Read-only Command replay Cert practice

See Which Packages Want Updates

Before you upgrade anything, list what would move.

apt list --upgradable
Linux Survival Basics safe
Read-only Command replay Cert practice

Check One Installed Package Cleanly

For one package, dpkg-query gives a clean status line.

dpkg-query -W -f='${Status} ${Version}\n' openssl
Linux Survival Basics safe
Read-only Command replay Cert practice

Find Which Package Owns a File

That binary came from somewhere. dpkg can tell you where.

dpkg-query -S /usr/sbin/nginx
Linux Survival Basics safe
Read-only Command replay Cert practice

Find Broken or Leftover dpkg States

Not every package row is cleanly installed.

dpkg-query -W -f='${db:Status-Abbrev}\t${Package}\n' | awk '$1 !~ /^ii$/'
Linux Survival Basics safe
Read-only Command replay Cert practice

Find the Largest Installed Packages

Disk cleanup starts with evidence, not random package removal.

dpkg-query -W -f='${Installed-Size}\t${Package}\n' | sort -nr | head -20
Linux Survival Basics safe
Read-only Command replay Cert practice

Spot Foreign-Architecture Packages

One unexpected architecture can explain confusing dependency output.

dpkg-query -W -f='${Architecture}\t${Package}\n' | awk '$1 != "amd64" && $1 != "all"'
Cybersecurity Triage safe
Read-only Command replay Cert practice

Simulate Security Package Upgrades

Security patch triage starts by seeing what apt would change, without changing it.

apt-get -s upgrade | awk '/^Inst/ && /security/ {print}'
Cybersecurity Triage safe
Read-only Command replay Cert practice

Prove a Package Candidate Is From Security

The package name is not enough; the candidate repository tells the patch story.

apt-cache policy openssl | sed -n '/Installed:/p;/Candidate:/p;/security/p'
Cybersecurity Triage safe
Read-only Command replay Cert practice

Find Held Packages Blocking Patches

A held package can quietly keep a security update out of production.

apt-mark showhold | sed 's/^/held: /'
Cybersecurity Triage safe
Read-only Command replay Cert practice

Review Kept-Back Packages Before Patching

Kept-back packages are where simple upgrade plans stop being simple.

apt-get -s upgrade | sed -n '/kept back:/,/^Inst/p'
Cybersecurity Triage safe
Read-only Command replay Cert practice

Dry-Run Unattended Security Upgrades

Unattended upgrades can explain what they would patch before they patch it.

unattended-upgrade --dry-run --debug 2>&1 | sed -n '/Packages that will be upgraded:/,/^$/p'
Cybersecurity Triage safe
Read-only Command replay Cert practice

Find Services Needing Restart After Patches

A patched library does not protect a process still using the old one.

needrestart -b | sed -n 's/^NEEDRESTART-SVC: //p'
Cybersecurity Triage safe
Read-only Command replay Cert practice

Build a Recent Apt Patch Timeline

Apt history turns patch claims into timestamps and package names.

awk '/^(Start-Date|Commandline|Upgrade|End-Date)/ {print}' /var/log/apt/history.log
Cybersecurity Triage safe
Read-only Command replay Cert practice

Find Warnings in Apt Terminal Logs

The package installed, but the terminal log may still contain the warning that matters.

grep -Ei 'warning|error|failed|dpkg' /var/log/apt/term.log
Cybersecurity Triage safe
Read-only Command replay Cert practice

Preview Security Impact of dist-upgrade

Kernel and dependency security fixes may only appear in the broader upgrade plan.

apt-get -s dist-upgrade | awk '/^Inst/ {print}'
Cybersecurity Triage safe
Read-only Command replay Cert practice

Check Whether Patches Require Reboot

Some security fixes are not complete until the host boots the new kernel or libraries.

test -f /var/run/reboot-required && printf 'reboot-required\n' && cat /var/run/reboot-required.pkgs
Hosting Operations safe
Read-only Command replay Cert practice

Tail the Failing CI Lines

Skip the full CI log and jump straight to lines that usually explain the failure.

grep -RInE 'error|failed|exception|traceback|fatal' logs/ | tail -50
Hosting Operations safe
Read-only Command replay Cert practice

List Newest Build Artifacts

Confirm what your pipeline actually produced before you deploy it.

find artifacts/ -type f -printf '%TY-%Tm-%Td %TH:%TM %10s %p\n' | sort | tail -20
Web Server Rescue safe
Read-only Command replay Cert practice

Check the Current Release Symlink

One glance tells you which release directory production is pointing at.

readlink -f releases/current && ls -ld releases/current
Linux Survival Basics safe
Read-only Command replay Cert practice

Find the Largest CI Logs

Huge logs often point to loops, noisy tests, or runaway debug output.

find logs/ -type f -printf '%s %p\n' | sort -nr | head -10
Hosting Operations safe
Read-only Command replay Cert practice

Show Release Directory Ages

See your newest release directories without opening a dashboard.

find releases/ -mindepth 1 -maxdepth 1 -type d -printf '%T@ %TY-%Tm-%Td %TH:%TM %p\n' | sort -nr | head -10 | cut -d' ' -f2-
Cybersecurity Triage safe
Read-only Command replay Cert practice

Extract Environment Names Only

Audit environment labels without printing secret values.

grep -RhoE 'ENVIRONMENT|NODE_ENV|APP_ENV|RAILS_ENV' config deploy | sort -u
Web Server Rescue safe
Read-only Command replay Cert practice

Smoke Check an HTTP Status

A deploy is not done until the endpoint answers.

curl -fsS -o /dev/null -w '%{http_code} %{time_total}s\n' https://example.com/health
Hosting Operations safe
Read-only Command replay Cert practice

Compare Artifact Checksums

Verify two artifact copies match before blaming deployment code.

sha256sum artifacts/app.tar.gz releases/current/app.tar.gz
Linux Survival Basics safe
Read-only Command replay Cert practice

Count Failures by Test File

Turn noisy test logs into a ranked failure list.

grep -RhoE '[A-Za-z0-9_./-]+\.(test|spec)\.(js|ts|py|rb)' logs/ | sort | uniq -c | sort -nr | head
Web Server Rescue safe
Read-only Command replay Cert practice

Inspect Release Disk Usage

Disk pressure during deploys often starts in old release directories.

du -sh releases/* 2>/dev/null | sort -h | tail -10
Hosting Operations safe
Read-only Command replay Cert practice

Check Image Tags in Manifests

Find the image tags your deployment files reference without printing env values.

grep -RhoE 'image:[[:space:]]*[^[:space:]]+' deploy/ | sort -u
Hosting Operations safe
Read-only Command replay Cert practice

Check Bytes and Inodes Before Cleanup

No space left can mean full bytes, full inodes, or both.

df -h /lab/disk-inode-cleanup && df -ih /lab/disk-inode-cleanup
Hosting Operations safe
Read-only Command replay Cert practice

Keep du on One Filesystem

A cleanup scan should not wander into mounted backups or network storage.

du -xh --max-depth=1 /lab/disk-inode-cleanup/var 2>/dev/null | sort -h
Hosting Operations safe
Read-only Command replay Cert practice

Preview Old Temp Files Before Deleting

The safe version of cleanup is a candidate list first.

find /lab/disk-inode-cleanup/var/tmp/uploads -xdev -type f -mtime +7 -printf '%TY-%Tm-%Td %10s %p\n' | sort
Hosting Operations safe
Read-only Command replay Cert practice

Find Directories Burning Inodes

Inode cleanup starts by finding the directory with too many files.

find /lab/disk-inode-cleanup/var/cache/app -xdev -type f -printf '%h\n' | sort | uniq -c | sort -nr | head
Hosting Operations safe
Read-only Command replay Cert practice

List Empty Directories as Cleanup Candidates

Empty directories are low-risk candidates, but they still deserve a preview.

find /lab/disk-inode-cleanup/var/cache/app -xdev -depth -type d -empty -print
Hosting Operations safe
Read-only Command replay Cert practice

Exclude the Current Release from Cleanup

Release cleanup should prove what current points to before listing old directories.

current=$(readlink -f /lab/disk-inode-cleanup/home/deploy/current); find /lab/disk-inode-cleanup/home/deploy/releases -mindepth 1 -maxdepth 1 -type d ! -samefile "$current" -printf '%TY-%Tm-%Td %p\n' | sort
Hosting Operations safe
Read-only Command replay Cert practice

Rank Old Cleanup Candidates by Size

The oldest file is not always the file that buys back meaningful space.

find /lab/disk-inode-cleanup/var -xdev -type f -mtime +7 -printf '%s %TY-%Tm-%Td %p\n' | sort -nr | head
Hosting Operations safe
Read-only Command replay Cert practice

Review Log Files Before Cleanup

Before truncating logs, prove which log files are large and how old they are.

find /lab/disk-inode-cleanup/var/log -xdev -type f -printf '%10s %TY-%Tm-%Td %p\n' | sort -nr
Hosting Operations safe
Read-only Command replay Cert practice

Summarize Cache File Ages

Cache cleanup is safer when you know whether files are stale or still active.

find /lab/disk-inode-cleanup/var/cache/app -xdev -type f -printf '%TY-%Tm-%Td\n' | sort | uniq -c
Dangerous Commands caution
Needs caution Command replay Cert practice

Print a Dry-Run Removal Script

The reviewable cleanup command is the one you print before you run.

find /lab/disk-inode-cleanup/var/tmp/uploads -xdev -type f -mtime +7 -printf 'rm -i -- %p\n'
Web Server Rescue safe
Read-only Command replay Cert practice

Compare DNS Answers Across Resolvers

One resolver can still have the old edge IP while another has the new one.

for r in 1.1.1.1 8.8.8.8 9.9.9.9; do printf '%s ' "$r"; dig @"$r" +short edge.test A; done
Web Server Rescue safe
Read-only Command replay Cert practice

Compare Authoritative Nameserver Answers

The recursive resolver was not the problem. One nameserver disagreed.

for ns in $(dig +short NS edge.test); do printf '%s ' "$ns"; dig @"$ns" +short edge.test A; done
Web Server Rescue safe
Read-only Command replay Cert practice

Show the DNS Answer TTL

The fix was correct. The TTL explained why users still saw the old edge.

dig +noall +answer edge.test A
Web Server Rescue safe
Read-only Command replay Cert practice

Check the WWW CNAME Target

The apex was right. The www name pointed through a different path.

dig +short www.edge.test CNAME
Web Server Rescue safe
Read-only Command replay Cert practice

Compare A and AAAA Records

IPv4 worked. IPv6 sent users to a different edge.

printf 'A '; dig +short edge.test A; printf 'AAAA '; dig +short edge.test AAAA
Web Server Rescue safe
Read-only Command replay Cert practice

Check CAA Certificate Issuers

The certificate request failed because DNS allowed the wrong issuer.

dig +short edge.test CAA
Web Server Rescue safe
Read-only Command replay Cert practice

Show TLS Certificate Dates

The outage was not the web server. The edge certificate had expired.

openssl s_client -connect edge.test:443 -servername edge.test </dev/null 2>/dev/null | openssl x509 -noout -dates
Web Server Rescue safe
Read-only Command replay Cert practice

Show TLS Certificate Names

The cert was valid, but not for this hostname.

openssl s_client -connect edge.test:443 -servername edge.test </dev/null 2>/dev/null | openssl x509 -noout -subject -ext subjectAltName
Web Server Rescue safe
Read-only Command replay Cert practice

Check the Certificate Served for SNI

The IP was right. The SNI name selected the wrong certificate.

openssl s_client -connect 203.0.113.10:443 -servername wrong.edge.test </dev/null 2>/dev/null | openssl x509 -noout -subject -ext subjectAltName
Web Server Rescue safe
Read-only Command replay Cert practice

Show TLS Protocol and Cipher

The certificate was fine. The TLS negotiation told the rest of the story.

openssl s_client -connect edge.test:443 -servername edge.test </dev/null 2>/dev/null | awk '/Protocol|Cipher|Verify return code/ {print}'
Hosting Operations safe
Read-only Command replay Cert practice

Show Containers in a Clean Triage Table

Turn noisy docker ps output into the few fields operators scan first.

docker ps -a --format 'table {{.Names}}\t{{.Status}}\t{{.Image}}\t{{.Ports}}'
Web Server Rescue safe
Read-only Command replay Cert practice

Find Restarting Containers Fast

Restart loops hide in plain sight unless you filter for them.

docker ps -a --filter status=restarting --format 'table {{.Names}}\t{{.Status}}\t{{.Image}}'
Hosting Operations safe
Read-only Command replay Cert practice

Check Container Health Status

Docker may say a container is running while its health check says otherwise.

docker inspect --format '{{.Name}} health={{if .State.Health}}{{.State.Health.Status}}{{else}}none{{end}} status={{.State.Status}}' web
Web Server Rescue caution
Needs caution Command replay Cert practice

Read Recent Container Logs

Skip the million-line log scroll and read only the recent failure window.

docker logs --since 10m --tail 100 api
Hosting Operations safe
Read-only Command replay Cert practice

Snapshot Container CPU and Memory

Get Docker resource usage once, without leaving a live dashboard running.

docker stats --no-stream --format 'table {{.Name}}\t{{.CPUPerc}}\t{{.MemUsage}}\t{{.NetIO}}\t{{.BlockIO}}'
Web Server Rescue safe
Read-only Command replay Cert practice

Show Published Container Ports

When a service is unreachable, confirm Docker is publishing the port you think it is.

docker port web
Hosting Operations safe
Read-only Command replay Cert practice

Summarize Docker Disk Usage

See how Docker storage is split across images, containers, volumes, and cache.

docker system df -v
Cybersecurity Triage caution
Needs caution Command replay Cert practice

Inspect Container Environment Names

Check what environment variables exist without printing their secret values.

docker inspect --format '{{range .Config.Env}}{{println .}}{{end}}' api | sed 's/=.*$/=<redacted>/'
Hosting Operations safe
Read-only Command replay Cert practice

See Container Network Attachments

A container can be healthy and still attached to the wrong network.

docker inspect --format '{{.Name}} {{range $name, $net := .NetworkSettings.Networks}}{{$name}} {{$net.IPAddress}} {{end}}' api
Cybersecurity Triage safe
Read-only Command replay Cert practice

Review Recent Docker Events

Docker keeps a recent event trail for starts, stops, pulls, and health changes.

docker events --since 30m --until 0s
Cybersecurity Triage safe
Read-only Command replay Cert practice

Read UFW Policy Verbosely

The firewall was active, but the defaults mattered more than the rule list.

ufw status verbose
Cybersecurity Triage safe
Read-only Command replay Cert practice

List Numbered UFW Rules

Numbered rules make firewall review less ambiguous.

ufw status numbered
Cybersecurity Triage safe
Read-only Command replay Cert practice

Show the nftables Input Chain

The packet path was hiding below UFW.

nft list ruleset | sed -n '/chain input/,/}/p'
Cybersecurity Triage safe
Read-only Command replay Cert practice

Show iptables INPUT Rules

Legacy firewall state can still explain live exposure.

iptables -S INPUT
Cybersecurity Triage safe
Read-only Command replay Cert practice

List Listening TCP Sockets

Firewall rules matter after you know what is listening.

ss -ltnp
Cybersecurity Triage safe
Read-only Command replay Cert practice

Show Publicly Bound Listeners

Localhost services are different from public listeners.

ss -ltnp | awk 'NR==1 || $4 ~ /^(0[.]0[.]0[.]0|[[]::[]]|[*]):/'
Cybersecurity Triage safe
Read-only Command replay Cert practice

Find Allowed Ports with No Listener

An open firewall rule can outlive the service it was created for.

comm -23 <(ufw status numbered | awk '/ALLOW/ {print}' | grep -Eo '[0-9]+/(tcp|udp)' | cut -d/ -f1 | sort -u) <(ss -ltnp | awk '/LISTEN/ {n=split($4,a,":"); print a[n]}' | sort -u)
Cybersecurity Triage safe
Read-only Command replay Cert practice

Find Public Listeners Not Allowed by UFW

The process was public, but the firewall did not mention it.

comm -13 <(ufw status numbered | awk '/ALLOW/ {print}' | grep -Eo '[0-9]+/(tcp|udp)' | cut -d/ -f1 | sort -u) <(ss -ltnp | awk '$4 ~ /^(0[.]0[.]0[.]0|[[]::[]]|[*]):/ {n=split($4,a,":"); print a[n]}' | sort -u)
Cybersecurity Triage safe
Read-only Command replay Cert practice

Check Whether SSH Is Publicly Bound

SSH can be locked down by source and still bind publicly.

ss -ltnp | awk '$4 ~ /:22$/ && $4 !~ /^127[.]/ {print}'
Cybersecurity Triage safe
Read-only Command replay Cert practice

Show Local-Only Database Listeners

The database was listening, but only on localhost.

ss -ltnp | awk '$4 ~ /^127[.]0[.]0[.]1:(5432|3306|6379)$/ {print}'
Hosting Operations safe
Read-only Command replay Cert practice

Snapshot Git Status Before Recovery

Before rollback commands, capture the branch and dirty files.

cd /lab/git-recovery-rollback && git status --short --branch
Hosting Operations safe
Read-only Command replay Cert practice

Map Recent Release Commits

A rollback is easier when the last few release tags are visible.

cd /lab/git-recovery-rollback && git log --oneline --decorate --graph --all -8
Hosting Operations safe
Read-only Command replay Cert practice

Show Files Changed Since Last Good Release

Compare the suspect release against the last known-good tag.

cd /lab/git-recovery-rollback && git diff --name-status release-2026-06-25-1000..HEAD
Hosting Operations safe
Read-only Command replay Cert practice

Find a Discarded Commit in Reflog

A reset does not mean the commit vanished.

cd /lab/git-recovery-rollback && git reflog --date=iso --format='%h %gd %gs' -6
Hosting Operations caution
Needs caution Command replay Cert practice

Branch a Recovered Commit

Put a name on the reflog commit before it slips away.

cd /lab/git-recovery-rollback && git branch recovered-incident-note HEAD@{1}
Hosting Operations caution
Needs caution Command replay Cert practice

Restore One File From Last Good Release

Recover a config file without rolling back the whole branch.

cd /lab/git-recovery-rollback && git restore --source=release-2026-06-25-1000 -- app/config.yml
Hosting Operations safe
Read-only Command replay Cert practice

Check the Active Release Symlink

Git may say one thing while the release pointer serves another.

cd /lab/git-recovery-rollback && readlink releases/current && cat releases/current/VERSION
Hosting Operations caution
Needs caution Command replay Cert practice

Rollback a Release Symlink in a Sandbox

Practice the pointer switch where the blast radius is zero.

cd /lab/git-recovery-rollback && ln -sfn 2026-06-25-1000 releases/current
Hosting Operations safe
Read-only Command replay Cert practice

Preview the Patch a Rollback Would Apply

Show the exact file changes before moving the branch back.

cd /lab/git-recovery-rollback && git diff --stat HEAD..release-2026-06-25-1000
Hosting Operations caution
Needs caution Command replay Cert practice

Revert the Suspect Release Commit

Undo a bad release with a new commit instead of rewriting history.

cd /lab/git-recovery-rollback && git restore -- app/config.yml && git revert --no-edit release-2026-06-25-1030
Hosting Operations safe
Read-only Command replay Cert practice

Test Nginx Before Reload

The config looked fine. Nginx disagreed before reload broke anything.

nginx -t
Hosting Operations safe
Read-only Command replay Cert practice

Show Enabled Nginx Sites

The config existed, but it was not enabled.

ls -l /etc/nginx/sites-enabled/
Hosting Operations safe
Read-only Command replay Cert practice

Find Which Nginx Config Owns a Domain

The wrong server block was answering the domain.

grep -R "server_name" /etc/nginx/sites-enabled/
Hosting Operations safe
Read-only Command replay Cert practice

Check HTTP to HTTPS Redirect

HTTPS worked. The plain HTTP redirect still mattered.

curl -I http://example.com
Hosting Operations safe
Read-only Command replay Cert practice

Inspect Response Headers

The page loaded, but the headers told the operational story.

curl -sI https://example.com
Hosting Operations safe
Read-only Command replay Cert practice

Check a Domain A Record

The site was fine. The domain was pointed somewhere else.

dig +short example.com A
Hosting Operations safe
Read-only Command replay Cert practice

List Certbot Certificates

The certificate existed. The question was which domains it covered.

certbot certificates
Hosting Operations safe
Read-only Command replay Cert practice

Check the Current Release Symlink

The deploy finished. The symlink told me what was actually live.

readlink -f /srv/www/example.com/current
Hosting Operations safe
Read-only Command replay Cert practice

Find Top 404 URLs

The missing file was not random. The access log had a pattern.

awk '$9==404 {print $7}' /var/log/nginx/access.log | sort | uniq -c | sort -nr | head
Hosting Operations safe
Read-only Command replay Cert practice

See Top Referrers

LinkedIn traffic was not a guess. The referrer field showed it.

awk -F'"' '{print $4}' /var/log/nginx/access.log | sort | uniq -c | sort -nr | head
Hosting Operations safe
Read-only Command replay Cert practice

Summarize Journal Severity During an Incident

Start with severity counts before opening every log line.

journalctl -p warning..alert --since "2 hours ago" --no-pager -o short-iso | awk '{count[$4]++} END {for (level in count) print count[level], level}' | sort -nr
Hosting Operations safe
Read-only Command replay Cert practice

Group Journal Errors by Unit

A noisy incident usually has a noisy source.

journalctl -p err..alert --since "2 hours ago" --no-pager -o short-iso | awk '{split($3,a,"["); unit=a[1]; count[unit]++} END {for (u in count) print count[u], u}' | sort -nr
Hosting Operations safe
Read-only Command replay Cert practice

Print a Critical Journal Timeline

Timeline beats guesswork when several failures happen close together.

journalctl -p err..alert --since "2 hours ago" --no-pager -o short-iso | awk '{print $1, $3, $4, substr($0,index($0,$5))}'
Linux Survival Basics safe
Read-only Command replay Cert practice

Show Context Around the First App Error

The first error often explains more than the last one.

awk '{buf[NR%5]=$0} tolower($0) ~ /(error|exception|fatal)/ {for (i=NR-4;i<=NR;i++) if (i>0) print buf[i%5]; exit}' fixtures/incidents/app.log
Hosting Operations safe
Read-only Command replay Cert practice

Count App Errors by Minute

A minute-by-minute count shows whether an incident is a spike or a drip.

awk 'tolower($0) ~ /(error|fatal|timeout|exception)/ {minute=substr($1,1,16); count[minute]++} END {for (m in count) print count[m], m}' fixtures/incidents/app.log | sort -nr
Hosting Operations safe
Read-only Command replay Cert practice

Count Request IDs in Error Lines

Repeated request IDs can connect separate error lines to one failing path.

grep -Ei 'error|timeout|fatal|exception' fixtures/incidents/app.log | awk '{for (i=1;i<=NF;i++) if ($i ~ /^request_id=/) print $i}' | sort | uniq -c | sort -nr
Hosting Operations safe
Read-only Command replay Cert practice

Build a Deploy and Restart Timeline

Deploys and restarts are incident landmarks.

grep -Eh 'deploy|release|restart|started|stopped|rolled back' fixtures/incidents/*.log | sort
Linux Survival Basics safe
Read-only Command replay Cert practice

Spot OOM Kills in the Kernel Journal

Exit code 137 often means the kernel has something to say.

journalctl -k --since "2 hours ago" --no-pager -o short-iso | grep -Ei 'out of memory|oom|killed process'
Hosting Operations safe
Read-only Command replay Cert practice

Find the Noisiest Incident Log Files

The biggest log is not always right, but it is worth knowing.

wc -l fixtures/incidents/*.log | sort -nr
Cybersecurity Triage safe
Read-only Cert practice

Redact Secret-Looking Log Lines

Incident notes should not copy secrets forward.

grep -RInE '(password=|token=|secret=|Authorization: Bearer)' fixtures/incidents | awk '{gsub(/password=[^ ]+/, "password=REDACTED"); gsub(/token=[^ ]+/, "token=REDACTED"); gsub(/secret=[^ ]+/, "secret=REDACTED"); gsub(/Authorization: Bearer [A-Za-z0-9._-]+/, "Authorization: Bearer REDACTED"); print}'
Cybersecurity Triage safe
Read-only Command replay Cert practice

Find Writable Directories Missing the Sticky Bit

A writable log directory is not the same thing as a safe shared directory.

find fixtures/perm-audit -type d -perm -0002 ! -perm -1000 -printf '%m %u:%g %p\n' | sort
Hosting Operations safe
Read-only Command replay Cert practice

Find Release Files Writable Outside the Owner

A release file that someone besides the owner can modify deserves a second look.

find fixtures/perm-audit/releases/2026-06-25 -type f -perm /0022 -printf '%M %u:%g %p\n' | sort
Hosting Operations safe
Read-only Command replay Cert practice

Find Runtime Directories Writable Outside the Owner

Runtime directories often need writes, but the write boundary should be visible.

find fixtures/perm-audit/releases/2026-06-25/storage fixtures/perm-audit/releases/2026-06-25/uploads -type d -perm /0022 -printf '%M %u:%g %p\n' | sort
Cybersecurity Triage safe
Read-only Command replay Cert practice

Find SUID, SGID, and Sticky Bits in an App Tree

Special bits are easy to miss in a long ls listing.

find fixtures/perm-audit -perm /7000 -printf '%M %m %u:%g %p\n' | sort
Hosting Operations safe
Read-only Command replay Cert practice

Group Writable Files by Owning Group

Group-writable files are not automatically wrong, but the owning group decides the risk.

find fixtures/perm-audit -type f -perm -0020 -printf '%g %M %p\n' | sort
Cybersecurity Triage safe
Read-only Command replay Cert practice

Find World-Readable Secret-Looking Files

The fastest secret audit starts with readable files that look like secrets.

find fixtures/perm-audit -type f -perm -0004 \( -iname '*secret*' -o -iname '*.env' -o -iname '*token*' -o -iname '*key*' \) -printf '%M %u:%g %p\n' | sort
Cybersecurity Triage safe
Read-only Command replay Cert practice

Find Config Files with Execute Bits

Config files do not usually need to be executable.

find fixtures/perm-audit -type f -perm /111 \( -path '*/config/*' -o -name '*.env' -o -name '*.conf' \) -printf '%M %u:%g %p\n' | sort
Hosting Operations safe
Read-only Command replay Cert practice

Audit a Symlink Permission Chain

A symlink can make the path you audited different from the file the app opens.

find fixtures/perm-audit -type l -printf '%p -> %l\n' -exec namei -l {} \;
Cybersecurity Triage safe
Read-only Command replay Cert practice

Find Upload Files Writable Outside the Owner

Uploads are supposed to be writable at the edge, not writable forever by everyone.

find fixtures/perm-audit/releases/2026-06-25/uploads -type f -perm /0022 -printf '%M %u:%g %p\n' | sort
Hosting Operations safe
Read-only Command replay Cert practice

Find the Processes Burning CPU

A server feels slow, but you need proof before restarting anything.

ps -eo pid,ppid,stat,pcpu,pmem,comm,args --sort=-pcpu | head -n 10
Hosting Operations safe
Read-only Command replay Cert practice

Find the Processes Eating Memory

Memory pressure can look like a slow app, a stuck deploy, or random crashes.

ps -eo pid,ppid,stat,pcpu,pmem,rss,comm,args --sort=-pmem | head -n 10
Linux Survival Basics safe
Read-only Command replay Cert practice

Check Memory Pressure with free

Linux memory numbers look scary until you know which column matters.

free -h
Web Server Rescue safe
Read-only Command replay Cert practice

Check Filesystem Space with df

A full disk can break logins, uploads, databases, and deploys.

df -h
Web Server Rescue safe
Read-only Command replay Cert practice

Find Large Directories with du

Once you know a filesystem is full, the next question is where.

du -xh --max-depth=1 /var 2>/dev/null | sort -h
Cybersecurity Triage safe
Read-only Command replay Cert practice

Find Listening Ports with ss

Before blaming the firewall, check whether anything is actually listening.

ss -ltnp
Hosting Operations safe
Read-only Command replay Cert practice

Find Open Deleted Files with lsof

A file can be deleted but still occupy disk while a process holds it open.

lsof +L1
Cybersecurity Triage safe
Read-only Command replay Cert practice

Inspect Established Network Connections

Unexpected connections are easier to reason about when you can see them directly.

ss -tan state established
Linux Survival Basics safe
Read-only Command replay Cert practice

Show the Real User Cron Jobs

Cron problems often hide behind comments, blank lines, and copied folklore.

crontab -l | sed -n '/^[[:space:]]*#/d;/^[[:space:]]*$/d;p'
Hosting Operations safe
Read-only Command replay Cert practice

Find System Cron Files Fast

A job can be nowhere in your crontab and still run every night.

find /etc/cron.d /etc/cron.hourly /etc/cron.daily /etc/cron.weekly /etc/cron.monthly -maxdepth 1 -type f -print 2>/dev/null | sort
Linux Survival Basics safe
Read-only Command replay Cert practice

Turn Cron Into a Readable Table

Cron is easier to debug when the schedule and command stop blending together.

crontab -l | awk 'NF && $1 !~ /^#/ {printf "%-16s %s\n", $1" "$2" "$3" "$4" "$5, substr($0,index($0,$6))}'
Hosting Operations safe
Read-only Command replay Cert practice

Find Cron Jobs With No Log Trail

A silent cron job is a future incident with no witness.

crontab -l | awk 'NF && $1 !~ /^#/ && $0 !~ /(>>|2>|logger|mail)/ {print}'
Linux Survival Basics safe
Read-only Command replay Cert practice

Map systemd Timers to Services

A timer is only half the scheduled job. The service is the payload.

systemctl list-timers --all --no-pager --plain | awk 'NR==1 || /\.timer/ {print $(NF-1), "->", $NF}'
Hosting Operations safe
Read-only Command replay Cert practice

Spot Stale systemd Timers

The suspicious timer is the one with no next run.

systemctl list-timers --all --no-pager --plain | awk 'NR==1 || $1=="n/a" || /backup\.timer|logrotate\.timer/'
Hosting Operations safe
Read-only Command replay Cert practice

Check the Last Timer Payload Logs

When a timer fires, the useful logs are usually on the service.

journalctl -u backup.service -n 20 --no-pager
Hosting Operations safe
Read-only Command replay Cert practice

Dry-Run Logrotate Before Touching Logs

Logrotate can explain its plan without rotating anything.

logrotate -d /etc/logrotate.conf 2>&1 | sed -n '/rotating pattern/p;/considering log/p;/error:/p'
Hosting Operations safe
Read-only Command replay Cert practice

Find Logs Missing Logrotate Coverage

The biggest log risk is often the file no policy mentions.

find /var/log -type f -name '*.log' -printf '%p\n' | while read -r log; do grep -Rqs -- "$log" /etc/logrotate.conf /etc/logrotate.d || grep -Rqs -- "$(dirname "$log")/[*].log" /etc/logrotate.conf /etc/logrotate.d || printf '%s\n' "$log"; done
Linux Survival Basics safe
Read-only Command replay Cert practice

List Tables in a SQLite Database

Before querying a database file, see what tables are actually inside it.

sqlite3 app.db ".tables"
Hosting Operations safe
Read-only Command replay Cert practice

Show One SQLite Table Schema

A failed query is often just a wrong assumption about column names.

sqlite3 app.db ".schema users"
Hosting Operations safe
Read-only Command replay Cert practice

Check SQLite Database Integrity

When a SQLite-backed app behaves strangely, first rule out file corruption.

sqlite3 app.db "PRAGMA integrity_check;"
Hosting Operations safe
Read-only Command replay Cert practice

List SQLite User Tables Only

System metadata tables can distract from the app tables you care about.

sqlite3 app.db "SELECT name FROM sqlite_master WHERE type='table' ORDER BY name;"
Hosting Operations safe
Read-only Command replay Cert practice

Count Rows in Key SQLite Tables

A quick row count can reveal empty imports, runaway events, or missing data.

sqlite3 app.db "SELECT 'users', count(*) FROM users UNION ALL SELECT 'orders', count(*) FROM orders UNION ALL SELECT 'events', count(*) FROM events;"
Hosting Operations safe
Read-only Command replay Cert practice

Show Indexes on a SQLite Table

Slow lookups often start with missing or misunderstood indexes.

sqlite3 app.db "PRAGMA index_list('orders');"
Hosting Operations safe
Read-only Command replay Cert practice

Show Recent SQLite Events

For small apps, the quickest timeline may be inside the SQLite file.

sqlite3 app.db "SELECT created_at, event_type FROM events ORDER BY created_at DESC LIMIT 5;"
Hosting Operations safe
Read-only Command replay Cert practice

Count SQLite Events by Type

A noisy event type stands out faster when you group it.

sqlite3 app.db "SELECT event_type, count(*) FROM events GROUP BY event_type ORDER BY count(*) DESC;"
Hosting Operations safe
Read-only Command replay Cert practice

Find Duplicate Emails in SQLite

Duplicate account data is easier to spot with one grouped query.

sqlite3 app.db "SELECT email, count(*) FROM users GROUP BY email HAVING count(*) > 1;"
Hosting Operations caution
Needs caution Command replay Cert practice

Back Up a SQLite Database File

Copying a live SQLite file blindly can produce a bad backup.

sqlite3 app.db ".backup backup/app.db"
Cybersecurity Triage safe
Read-only Command replay Cert practice

Summarize SSH Auth Outcomes

SSH logs get easier to read once accepted and failed methods are counted.

awk '/sshd/ && /Accepted/ {print "accepted", $7} /sshd/ && /Failed password/ {print "failed", "password"} /sshd/ && /Failed publickey/ {print "failed", "publickey"}' logs/auth.log | sort | uniq -c | sort -nr
Cybersecurity Triage safe
Read-only Command replay Cert practice

Find SSH Password Auth Exceptions

A global password-auth setting can be changed later by a Match block.

awk '/^Match /{ctx=$0} /^PasswordAuthentication|^AuthenticationMethods|^[[:space:]]+PasswordAuthentication|^[[:space:]]+AuthenticationMethods/ {print (ctx ? ctx : "global") ": " $0}' etc/ssh/sshd_config
Cybersecurity Triage safe
Read-only Command replay Cert practice

List SSH Allow and Deny Rules

SSH access can be shaped by users, groups, and Match blocks.

grep -RhnE '^(AllowUsers|AllowGroups|DenyUsers|DenyGroups|Match )' etc/ssh
Cybersecurity Triage safe
Read-only Command replay Cert practice

Inventory SSH authorized_keys

authorized_keys files are the practical list of who can use key-based SSH.

find home -path '*/.ssh/authorized_keys' -exec awk '{print FILENAME, $1, $NF}' {} +
Cybersecurity Triage safe
Read-only Command replay Cert practice

List Accepted SSH Login Sources

Successful SSH logins are the access events worth anchoring first.

awk '/Accepted publickey/ {print $1, $2, $3, $9, $11}' logs/auth.log
Cybersecurity Triage safe
Read-only Command replay Cert practice

Show Failed SSH Public-Key Users

A failed public-key attempt often points to stale keys or the wrong account.

awk '/Failed publickey/ {print $9, $11}' logs/auth.log | sort | uniq -c | sort -nr
Cybersecurity Triage safe
Read-only Command replay Cert practice

Summarize SSH Authorized Key Types

Key inventory gets more useful when old key types stand out.

find home -path '*/.ssh/authorized_keys' -exec awk '{print $1}' {} + | sort | uniq -c | sort -nr
Cybersecurity Triage safe
Read-only Command replay Cert practice

Find Loose authorized_keys Modes

SSH key access files should not be looser than intended.

find home -path '*/.ssh/authorized_keys' -printf '%m %p\n' | awk '$1 > 600'
Cybersecurity Triage safe
Read-only Command replay Cert practice

Show SSH Auth Policy Order

The order of Include, Match, and authentication directives changes how SSH policy reads.

grep -nE '^(Include|Match |PubkeyAuthentication|PasswordAuthentication|AuthenticationMethods|[[:space:]]+(PasswordAuthentication|AuthenticationMethods))' etc/ssh/sshd_config
Cybersecurity Triage safe
Read-only Command replay Cert practice

Extract SSH AllowUsers Accounts

AllowUsers turns SSH access into an explicit account list.

awk '/^AllowUsers/ {for (i = 2; i <= NF; i++) print $i}' etc/ssh/sshd_config
Hosting Operations safe
Read-only Command replay Cert practice

Find Duplicate Page Titles

Duplicate titles make a static site harder to scan in search results and browser tabs.

grep -Rho --include='*.html' '<title>[^<]*</title>' public | sed 's#<title>##;s#</title>##' | sort | uniq -c | sort -nr
Hosting Operations safe
Read-only Command replay Cert practice

Find Pages Missing Canonical Links

Canonical tags are easy to drop when templates branch.

find public -name '*.html' -print | while read -r f; do grep -qi 'rel="canonical"' "$f" || echo "$f"; done
Hosting Operations safe
Read-only Command replay Cert practice

Find Pages Marked noindex

A leftover noindex can hide a page after launch.

grep -Rni --include='*.html' 'noindex' public
Hosting Operations safe
Read-only Command replay Cert practice

Find Pages Missing Meta Descriptions

Missing descriptions are usually a content template problem, not a mystery.

find public -name '*.html' -print | while read -r f; do grep -qi 'name="description"' "$f" || echo "$f"; done
Linux Survival Basics safe
Read-only Command replay Cert practice

List URLs from a Sitemap

Before comparing sitemap coverage, print the URLs plainly.

grep -o '<loc>[^<]*</loc>' public/sitemap.xml | sed 's#<loc>##;s#</loc>##'
Hosting Operations safe
Read-only Command replay Cert practice

Check robots.txt for a Sitemap Line

A sitemap can exist and still be hard to discover.

grep -n '^Sitemap:' public/robots.txt
Hosting Operations safe
Read-only Command replay Cert practice

Find HTML Pages Missing from the Sitemap

A page can exist in the build but never make it into the sitemap.

find public -name '*.html' -print | sed 's#^public#https://example.com#' | while read -r url; do grep -q "$url" public/sitemap.xml || echo "$url"; done
Web Server Rescue safe
Read-only Command replay Cert practice

Find Broken Internal Links in Built HTML

A broken internal link is easiest to catch before it becomes a 404.

grep -Rho --include='*.html' 'href="/[^"]*"' public | sed 's#href="##;s#"##' | while read -r path; do test -e "public${path}" || echo "$path"; done | sort -u
Hosting Operations safe
Read-only Command replay Cert practice

Find Pages Missing og:title

Social previews often fail because one template missed Open Graph tags.

find public -name '*.html' -print | while read -r f; do grep -qi 'property="og:title"' "$f" || echo "$f"; done
Hosting Operations safe
Read-only Command replay Cert practice

Find Feed Links Missing from the Sitemap

Your feed can advertise URLs that the sitemap never lists.

grep -o '<link>https://example.com/[^<]*</link>' public/feed.xml | sed 's#<link>##;s#</link>##' | while read -r url; do grep -q "$url" public/sitemap.xml || echo "$url"; done
Linux Survival Basics safe
Read-only Command replay Cert practice

Show Failed systemd Units

One command tells you which services systemd already knows are broken.

systemctl --failed --no-pager
Linux Survival Basics safe
Read-only Command replay Cert practice

Inspect One Service Without Pager Traps

Make systemctl status safe for scripts, screenshots, and quick incident notes.

systemctl status nginx --no-pager --lines=30
Linux Survival Basics safe
Read-only Command replay Cert practice

Read Current-Boot Logs for One Service

Ignore stale logs and inspect only what happened since this boot.

journalctl -u nginx -b --no-pager -n 80
Linux Survival Basics safe
Read-only Command replay Cert practice

Check systemd Journal Disk Usage

Before deleting random logs, ask journald how much disk it owns.

journalctl --disk-usage
Linux Survival Basics safe
Read-only Command replay Cert practice

Find Slow Services During Boot

Find which units made your VPS boot slowly.

systemd-analyze blame | head -20
Linux Survival Basics safe
Read-only Command replay Cert practice

Check Whether a Service Starts at Boot

Running now does not mean it will survive the next reboot.

systemctl is-enabled nginx
Linux Survival Basics safe
Read-only Command replay Cert practice

Check If a Service Is Active

Get a clean yes-or-no service state without the full status page.

systemctl is-active nginx
Linux Survival Basics safe
Read-only Command replay Cert practice

Show Recent Server Reboots

Confirm whether the server actually rebooted and when.

last -x reboot | head -5
Linux Survival Basics safe
Read-only Command replay Cert practice

Check Memory Pressure Quickly

See whether memory is actually tight before restarting services.

free -h
Linux Survival Basics safe
Read-only Command replay Cert practice

List Upcoming systemd Timers

Cron is not the only scheduler on modern Linux servers.

systemctl list-timers --all --no-pager
Linux Survival Basics safe
Read-only Command replay Cert practice

Read the Failure Cause in systemctl Status

The status page often tells you the failed startup step before you open every log.

systemctl status app-worker --no-pager --lines=50
Linux Survival Basics safe
Read-only Command replay Cert practice

Print the Exact systemd Exit Fields

Turn a noisy service failure into four fields you can paste into an incident note.

systemctl show app-worker --property=Result,ExecMainCode,ExecMainStatus,NRestarts --no-pager
Hosting Operations safe
Read-only Command replay Cert practice

Read Warning and Error Logs for One Failed Unit

Filter a failed unit's journal to the lines most likely to explain the stop.

journalctl -u app-worker -b -p warning..alert --no-pager -n 80
Hosting Operations safe
Read-only Command replay Cert practice

Build a Restart Loop Timeline

Restart loops make more sense when you line up starts, failures, and counters.

journalctl -u app-worker -b --no-pager -o short-iso | grep -E 'Started|Failed|Scheduled restart|Main process exited'
Hosting Operations safe
Read-only Command replay Cert practice

Print Runtime Paths and User From systemd

Confirm the user, working directory, env file, and ExecStart systemd is actually using.

systemctl show app-worker --property=FragmentPath,DropInPaths,EnvironmentFiles,ExecStart,User,WorkingDirectory --no-pager
Hosting Operations safe
Read-only Command replay Cert practice

Check Failed Dependencies for a Service

Sometimes the service is only the messenger for a failed dependency.

systemctl list-dependencies app-worker --failed --no-pager
Linux Survival Basics caution
Needs caution Command replay Cert practice

Reset Failed State After Capturing Evidence

Clear the red failed state only after you have captured the evidence.

systemctl reset-failed app-worker
Hosting Operations safe
Read-only Command replay Cert practice

Find the First Failure Line for One Unit

The first failure line is often more useful than the last restart message.

journalctl -u app-worker -b --no-pager -o short-iso | grep -m1 -E 'ERROR|Failed|status='
Linux Survival Basics safe
Read-only Command replay Cert practice

Compare Failure Output With the Effective Unit

Put the failed step next to the unit config that created it.

systemctl status app-worker --no-pager --lines=50 && systemctl cat app-worker
Cybersecurity Triage safe
Read-only Command replay Cert practice

List Accounts with Login Shells

Login shells are the first account inventory to review.

awk -F: '$7 ~ /(bash|sh|zsh)$/ {printf "%s %s\n", $1, $7}' fixtures/user-access-audit/etc/passwd
Cybersecurity Triage safe
Read-only Command replay Cert practice

Find Password-Enabled Accounts

A shell account with an unlocked password hash deserves extra attention.

awk -F: '$2 !~ /^(!|\*)/ {print $1}' fixtures/user-access-audit/etc/shadow
Cybersecurity Triage safe
Read-only Command replay Cert practice

Review sudo Grants

Privilege paths should be visible before you remove or approve access.

awk -F: '$1=="sudo" {print "sudo group: " $4}' fixtures/user-access-audit/etc/group; grep -RhnE '^[^#].*ALL=' fixtures/user-access-audit/etc/sudoers fixtures/user-access-audit/etc/sudoers.d
Cybersecurity Triage safe
Read-only Command replay Cert practice

Count authorized_keys by User

authorized_keys is the practical SSH access list.

find fixtures/user-access-audit/home -path '*/.ssh/authorized_keys' -exec sh -c 'for f do user=$(basename "$(dirname "$(dirname "$f")")"); keys=$(grep -vc "^[[:space:]]*#" "$f"); printf "%s %s %s\n" "$user" "$keys" "$f"; done' sh {} + | sort
Cybersecurity Triage safe
Read-only Command replay Cert practice

Find SSH Keys for nologin Users

A nologin shell does not automatically mean SSH keys are irrelevant.

comm -12 <(awk -F: '$7 !~ /(bash|sh|zsh)$/ {print $1}' fixtures/user-access-audit/etc/passwd | sort) <(find fixtures/user-access-audit/home -path '*/.ssh/authorized_keys' -printf '%h\n' | awk -F/ '{print $(NF-1)}' | sort)
Cybersecurity Triage safe
Read-only Command replay Cert practice

Show Successful Logins and sudo Use

Access reviews need both who logged in and who elevated privileges.

grep -E 'Accepted publickey|sudo:' fixtures/user-access-audit/logs/auth.log
Cybersecurity Triage safe
Read-only Command replay Cert practice

List Privileged Group Members

Group membership can grant more access than the username suggests.

awk -F: '$1 ~ /^(sudo|adm|docker)$/ && $4 != "" {print $1 ": " $4}' fixtures/user-access-audit/etc/group
Cybersecurity Triage safe
Read-only Command replay Cert practice

Summarize sudo Commands by User

Privilege history is easier to review when users and commands are separated.

sed -n 's/.*sudo: *\([^: ]*\).*COMMAND=\(.*\)$/\1 -> \2/p' fixtures/user-access-audit/logs/auth.log | sort
Cybersecurity Triage safe
Read-only Command replay Cert practice

Review a Breakglass Account

Emergency accounts should be easy to find and hard to ignore.

grep -Rhn 'breakglass' fixtures/user-access-audit/etc fixtures/user-access-audit/home fixtures/user-access-audit/logs
Cybersecurity Triage safe
Read-only Command replay Cert practice

Find SSH Key Users with sudo

The highest-priority access review starts where SSH keys and sudo overlap.

comm -12 <(find fixtures/user-access-audit/home -path '*/.ssh/authorized_keys' -printf '%h\n' | awk -F/ '{print $(NF-1)}' | sort) <(awk -F: '$1=="sudo" {gsub(",","\n",$4); print $4}' fixtures/user-access-audit/etc/group | sort)
Cybersecurity Triage safe
Read-only Command replay Cert practice

Count Failed SSH Login Users

Failed SSH attempts are noisy; grouping users makes the pattern readable.

sed -n 's/.*Failed password for \(invalid user \)\?\([^ ]*\) from .*/\2/p' logs/auth.log | sort | uniq -c | sort -nr
Cybersecurity Triage safe
Read-only Command replay Cert practice

Count Failed SSH Login IPs

The loudest SSH source is usually visible with one count.

sed -n 's/.*Failed password .* from \([0-9.]*\) port.*/\1/p' logs/auth.log | sort | uniq -c | sort -nr
Cybersecurity Triage safe
Read-only Command replay Cert practice

Show Accepted SSH Logins

During first response, successful logins matter more than background noise.

grep 'Accepted publickey' logs/auth.log
Cybersecurity Triage safe
Read-only Command replay Cert practice

Show Recent sudo Commands

Privilege use is one of the fastest first-response signals.

grep 'sudo:' logs/auth.log | tail -n 10
Cybersecurity Triage safe
Read-only Command replay Cert practice

List Listening Ports on a VPS

Unexpected network listeners are first-response evidence.

ss -ltnp
Cybersecurity Triage safe
Read-only Command replay Cert practice

List Users with Login Shells

Not every local account should be able to log in.

awk -F: '$7 ~ /sh$/ {print $1, $7}' etc/passwd
Cybersecurity Triage safe
Read-only Command replay Cert practice

Check Key SSH Authentication Settings

SSH policy should be visible before you change it.

grep -nE '^(PasswordAuthentication|PermitRootLogin|PubkeyAuthentication|AllowUsers)' etc/ssh/sshd_config
Cybersecurity Triage safe
Read-only Command replay Cert practice

Find World-Writable Web Directories

World-writable web paths deserve immediate review.

find srv/www -type d -perm -0002 -print
Cybersecurity Triage safe
Read-only Command replay Cert practice

Find Loose Private Key Permissions

SSH private keys should not be readable like ordinary files.

find home -type f -name 'id_*' -printf '%m %p\n' | awk '$1 > 600'
Cybersecurity Triage safe
Read-only Command replay Cert practice

List authorized_keys Files

Authorized keys are the server's practical access list.

find home -path '*/.ssh/authorized_keys' -printf '%m %p\n'
Hosting Operations safe
Read-only Command replay Cert practice

List Nginx Listen Directives

The site was configured, but the port was not.

grep -RInE '^[[:space:]]*listen[[:space:]]' fixtures/nginx/conf.d fixtures/nginx/sites-enabled
Hosting Operations safe
Read-only Command replay Cert practice

Find the Nginx Default Server

The wrong site answered because it was the fallback.

grep -RIn 'default_server' fixtures/nginx/conf.d fixtures/nginx/sites-enabled
Hosting Operations safe
Read-only Command replay Cert practice

Show Nginx Include Lines

The config was valid; it just was not included.

grep -RInE '^[[:space:]]*include[[:space:]]' fixtures/nginx/nginx.conf fixtures/nginx/conf.d fixtures/nginx/sites-enabled
Hosting Operations safe
Read-only Command replay Cert practice

Map Nginx Roots and Aliases

The URL was right. The filesystem path was not.

grep -RInE '^[[:space:]]*(root|alias)[[:space:]]' fixtures/nginx/conf.d fixtures/nginx/sites-enabled
Hosting Operations safe
Read-only Command replay Cert practice

Map Nginx Proxy Targets

Nginx was healthy. It was proxying to the wrong place.

grep -RInE '^[[:space:]]*proxy_pass[[:space:]]' fixtures/nginx/conf.d fixtures/nginx/sites-enabled
Hosting Operations safe
Read-only Command replay Cert practice

Show Enabled Apache Sites

The Apache config existed. The enabled symlink did not.

find fixtures/apache/sites-enabled -maxdepth 1 -type l -printf '%f -> %l\n' | sort
Hosting Operations safe
Read-only Command replay Cert practice

Map Apache Virtual Hosts

Apache chose a virtual host. You need to know which one.

grep -RInE '<VirtualHost|ServerName|ServerAlias' fixtures/apache/sites-enabled
Hosting Operations safe
Read-only Command replay Cert practice

Find Apache Document Roots

Apache was serving files from a different directory than expected.

grep -RInE '^[[:space:]]*DocumentRoot[[:space:]]' fixtures/apache/sites-enabled
Hosting Operations safe
Read-only Command replay Cert practice

Map Apache Proxy Rules

Apache was up. The reverse proxy target was wrong.

grep -RInE '^[[:space:]]*(ProxyPass|ProxyPassReverse)[[:space:]]' fixtures/apache/sites-enabled
Hosting Operations safe
Read-only Command replay Cert practice

Find Web Server Redirect Rules

The redirect loop was hiding in plain text.

grep -RInE 'return[[:space:]]+30[18]|rewrite[[:space:]]|Redirect[[:space:]]|RewriteRule|RewriteCond' fixtures/nginx fixtures/apache
Hosting Operations safe
Read-only Command replay Cert practice

Summarize HTTP Status Codes

Before chasing individual lines, get the shape of the whole log.

awk '{count[$9]++} END {for (code in count) print count[code], code}' ./fixtures/nginx/access.log | sort -nr
Cybersecurity Triage safe
Read-only Command replay Cert practice

Find the IPs Creating the Most 4xx Noise

One address can turn a normal access log into a wall of failed requests.

awk '$9 ~ /^4/ {count[$1]++} END {for (ip in count) print count[ip], ip}' ./fixtures/nginx/access.log | sort -nr | head
Hosting Operations safe
Read-only Command replay Cert practice

Group Server Errors by URL Path

A 500 spike is easier to triage when the broken path is obvious.

awk '$9 ~ /^5/ {count[$7]++} END {for (path in count) print count[path], path}' ./fixtures/nginx/access.log | sort -nr | head
Cybersecurity Triage safe
Read-only Command replay Cert practice

Spot Unusual HTTP Methods in Access Logs

Most site traffic is boring. The weird methods are worth a look.

awk '$6 !~ /^"(GET|POST|HEAD|OPTIONS)$/ {print $1, $6, $7, $9}' ./fixtures/nginx/access.log | sort | uniq -c | sort -nr
Cybersecurity Triage safe
Read-only Command replay Cert practice

Count the Most Common User Agents

A strange traffic spike often has a strange user agent.

awk -F'"' '{print $6}' ./fixtures/nginx/access.log | sort | uniq -c | sort -nr | head
Cybersecurity Triage safe
Read-only Command replay Cert practice

Find Common Admin Probe Paths

A site does not need WordPress to receive WordPress-looking probes.

awk '$7 ~ /(admin|login|wp-|phpmyadmin)/ {print $1, $7, $9}' ./fixtures/nginx/access.log | sort | uniq -c | sort -nr | head
Cybersecurity Triage safe
Read-only Command replay Cert practice

Find Paths Repeatedly Returning 404

One missing URL is normal. A repeated missing URL is a signal.

awk '$9==404 {count[$7]++} END {for (path in count) if (count[path] >= 3) print count[path], path}' ./fixtures/nginx/access.log | sort -nr | head
Cybersecurity Triage safe
Read-only Command replay Cert practice

Spot Request Bursts by Minute

Traffic spikes are easier to read when you bucket them by time.

awk '{minute=substr($4,2,17); count[minute]++} END {for (m in count) print count[m], m}' ./fixtures/nginx/access.log | sort -nr | head
Hosting Operations safe
Read-only Command replay Cert practice

Find Unusually Large Web Responses

A few huge responses can explain bandwidth, latency, and suspicious download patterns.

awk '$10 ~ /^[0-9]+$/ && $10 > 1000000 {print $10, $1, $7, $9}' ./fixtures/nginx/access.log | sort -nr | head
Cybersecurity Triage safe
Read-only Command replay Cert practice

Find Clients Repeating the Same Path

The suspicious pattern is sometimes one client hammering one URL.

awk '{key=$1 " " $7; count[key]++} END {for (k in count) if (count[k] >= 5) print count[k], k}' ./fixtures/nginx/access.log | sort -nr | head