Terminal Diagnostics: The SRE's Vital Signs๐
Part of a pathway: Debugging With Nothing But a Terminal
Consult the map
-
Debugging With Nothing But a Terminal โ step 2 of 20
โ SSH Mastery ยท you are here ยท Pipes and Redirection โ
The system is slow. Users are reporting timeouts. You SSH into the server and the prompt feels sluggish. What do you look for first?
Terminal diagnostic tools are the "stethoscopes" of the platform engineer. They allow you to observe the health of the CPU, memory, disk, and network in real-time. Mastering these tools is the difference between guessing what's wrong and knowing exactly where the bottleneck lies.
Installation๐
top, free, dmesg, and ss ship with every Linux distribution โ no install needed. Two tools in the checklist below don't:
sysstat is what provides iostat. Without it, skip straight to ss and dmesg in the checklist below.
Quick Start: The "First 60 Seconds" Checklist๐
When you land on a server during an incident, run these in order. A command without a stated pass/fail signal is useless mid-incident, so here's what to actually look for at each step:
| # | Check | Command | Looks fine | Investigate further |
|---|---|---|---|---|
| 1 | Load & CPU | uptime |
Load average below your core count | Load average above your core count โ CPU-bound |
| 2 | Memory | free -h |
available is a healthy chunk of total |
available is low and shrinking โ actual memory pressure |
| 3 | Disk space | df -h |
Well under 100% used | At or near 100% used โ disk-bound |
| 4 | Disk I/O | iostat -xz 1 (needs sysstat) |
Low %util, low await |
%util near 100% and await climbing โ I/O-bound |
| 5 | Network | ss -tulpn |
The ports you expect are listening | An expected port is missing, or an unexpected one is present |
| 6 | Kernel logs | dmesg -T \| tail -n 50 |
Nothing recent | OOM-killer messages, hardware errors, or repeated timeouts |
That order isn't arbitrary โ each check rules out one category before you move to the next:
graph TD
Start["System feels slow"] --> Load{"Load average above<br/>CPU core count?"}
Load -->|yes| CPU["CPU-bound<br/>htop, sort by CPU"]
Load -->|no| Mem{"'available' memory<br/>actually low?"}
Mem -->|yes| MemBound["Memory-bound<br/>free -h"]
Mem -->|no| Disk{"Disk near 100% full?"}
Disk -->|yes| DiskBound["Disk-bound<br/>df -h / du -sh"]
Disk -->|no| Net["Check the network<br/>ss -tulpn"]
style Start fill:#2d3748,stroke:#cbd5e0,stroke-width:2px,color:#fff
style Load fill:#d69e2e,stroke:#cbd5e0,stroke-width:2px,color:#000
style Mem fill:#d69e2e,stroke:#cbd5e0,stroke-width:2px,color:#000
style Disk fill:#d69e2e,stroke:#cbd5e0,stroke-width:2px,color:#000
style CPU fill:#2f855a,stroke:#cbd5e0,stroke-width:2px,color:#fff
style MemBound fill:#2f855a,stroke:#cbd5e0,stroke-width:2px,color:#fff
style DiskBound fill:#2f855a,stroke:#cbd5e0,stroke-width:2px,color:#fff
style Net fill:#2f855a,stroke:#cbd5e0,stroke-width:2px,color:#fff
Essential Diagnostic Tools๐
Three of the six checklist steps deserve a closer look โ the ones with a real gotcha attached:
-
Load Average
Why it matters: The fastest way to tell if the CPU is the bottleneck, no need to launch a full interactive session for a quick check.
Check Load Average 
Key insight: Compare that first load-average number to your core count from
nproc.8.42on a 4-core box means the system is oversaturated; the same number on a 16-core box is unremarkable.uptimealone is enough to answer "is the CPU the bottleneck" โhtop(ortop) is a nice-to-have on top of that, useful when you also need to see which process is responsible. -
free -h
Why it matters: Shows total, used, and available memory in human-readable format.
Key insight: Don't panic that "free" is only 100Mi โ
available(11Gi) is the column that matters. Linux uses unused RAM for disk caching and hands it back the instant a process needs it. -
df -h and du -sh
Why it matters:
dfshows partition usage;dufinds which specific directory is eating your space.Find What's Filling the Disk Key insight: A 100% full disk often causes silent failures in databases and logging agents โ
dusorted by size gets you to the culprit directory in one line.
Why Diagnostics Matter for Platform Work๐
Diagnostics are the foundation of Incident Response. You cannot fix what you cannot measure. In a distributed system, being able to quickly rule out "the server is full" or "the process is OOMing" saves precious time.
Common Scenarios๐
Identify the process hogging the CPU:
- Run
htop. - Press
Pto sort by CPU usage. - If it's a Java or Python app, it might be an infinite loop or heavy GC.
- Use
strace -p <pid>to see what system calls the process is making in real-time.
Why won't your new Nginx container start?
ss -tulpn | grep :80- This shows you exactly which process ID (PID) is already listening on port 80.
ssis the modern replacement for the oldernetstat.
df says the disk is full, but du can't find the files?
- A process might be holding a deleted file open.
- Use
lsof +L1to find deleted files that are still consuming space because a process hasn't closed them.
Most of the commands above have a faster or friendlier modern replacement worth knowing:
Key Diagnostic Commands๐
| Command | Purpose | Modern Alternative |
|---|---|---|
uptime |
One-line load average check | โ |
top |
Interactive, live process monitor | htop, btop |
netstat |
Network connections | ss |
ifconfig |
Interface config | ip addr |
find |
Finding files | fd |
du |
Disk usage per dir | dust |
tail -f |
Follow logs | multitail |
Practice Problems๐
Practice Problem 1: Identifying Memory Pressure
You run free -h and see that free is 100MB, but available is 4GB. Should you be worried about an Out-of-Memory (OOM) event?
Answer
No. Linux is designed to use almost all available RAM for disk caching to improve performance. The available column is the one that matters โ it tells you how much memory can be reclaimed for new processes without causing the system to swap.
Practice Problem 2: Finding a Process
You need to find the PID of a running process named sidekiq so you can kill it. What's the fastest command?
Answer
| Find a Process by Name | |
|---|---|
pgrep finds the PID, and -af shows the full command line so you can be sure you're targeting the right instance.
What's Next๐
If you're following the Debugging With Nothing But a Terminal pathway, the next step is Pipes and Redirection on the Linux site โ chaining these same commands together instead of running them one at a time. From there, grep is the next stop once you've ruled out "the box itself is fine" and need to know what the logs actually say.
Further Reading๐
Official Documentation๐
- The Brendan Gregg Blog - The gold standard for Linux performance analysis.
man proc- Understand the/procfilesystem where all this data comes from.
Related Tools & Alternatives๐
- btop - A high-performance, beautiful system monitor.
- Glances - An all-in-one cross-platform monitoring tool.
Deep Dives๐
- How the OS Scheduler Actually Decides - How the OS decides which process gets CPU time, the mechanism behind the load average this article tells you to check first.