Skip to content

Try “polymorphism”, “TCP handshake” or “git rebase”.

    Computer Basics / The Linux Command Line

    The Incident Toolkit: Solving the 11 p.m. Outage

    Back to Part 0. StudyBuddy is down. Here's the calm, ordered way through it, using only this file's commands.

    Chapter 12 of 124 min read

    Back to Part 0. StudyBuddy is down. Here's the calm, ordered way through it, using only this file's commands.

    Output
      1. Is the service running?            systemctl status studybuddy
      2. What do its logs say?              journalctl -u studybuddy --since "30 min ago" | tail -100
      3. Is the disk full?                  df -h
      4. What's filling it?                 sudo du -sh /var/log/* | sort -h | tail
      5. Is memory exhausted?               free -h    (and: dmesg | grep -i "killed process")
      6. Is the CPU overloaded?             uptime   ·   top
      7. Is it listening on its port?       ss -tlnp | grep 8000     (Mac: lsof -i :8000)
      8. Does it answer locally?            curl -v http://localhost:8000/health
      9. Can it reach its dependencies?     nc -vz 10.0.21.5 5432    ·   dig api.openai.com

    What each finding means:

    Symptom you findLikely meaningNext move
    status shows failed, logs end with a Python tracebackthe app crashed on start (bad config, bad deploy)read the traceback; roll back (current symlink, Ch 3)
    df -h shows / at 100%disk full — logs or temp files grewfind the big files with du; delete/rotate old logs
    deleted a big log but df still says fulla process still has it open (Operating Systems Ch 10)sudo lsof +L1 to find it; restart that process
    dmesg shows Out of memory: Killed process ... (uvicorn)the OOM killer (Operating Systems Ch 5)look for a memory leak; add memory limits and alerts
    load average far above core countCPU overloadedtop to find the process; scale out or fix the hot code
    nothing listening on 8000the app isn't running, or bound elsewherecheck the ExecStart line and --port
    listening, but curl to localhost hangsapp stuck (blocked event loop, deadlock — Operating Systems Ch 8–11)check logs, thread dumps; restart as a stopgap
    nc to the database times outfirewall / security group / route (Networking 2: TCP, UDP and Ports Ch 11)check the rules on both sides
    dig failsDNS problem (Networking 3: DNS, HTTP and HTTPS Ch 2)check /etc/resolv.conf, the resolver

    Useful commands not covered earlier:

    Terminal
    df -h                 # disk space per file system, human-readable
    du -sh *              # size of each item in this folder
    free -h               # RAM and swap use (Linux; on Mac use `vm_stat` or Activity Monitor)
    uptime                # how long since boot + load averages
    dmesg -T | tail       # kernel messages, with readable timestamps — OOM kills, disk errors
    ss -tlnp              # TCP sockets that are Listening, as Numbers, with the Process (Linux)
    lsof -i :8000         # which process uses port 8000 (Mac and Linux)

    After the fire is out: write down what happened, how you found it, and what will stop it happening again (log rotation, disk alerts, memory limits). That write-up is a postmortem, and interviewers love hearing about them (Observability in Practice (coming soon)).