Disk / Memory / CPU Troubleshooting
This page gives the fastest commands for capacity and performance issues. Each command includes a short one-line explanation for quick lookup.
Disk
| Command | What it does | Example |
|---|---|---|
df -h | Shows free and used disk space on filesystems. | df -h |
du -sh /var/log/* | Shows sizes of log directories. | du -sh /var/log/* |
find /var/log -type f -size +100M | Finds very large log files. | find /var/log -type f -size +100M |
iostat -xz 1 3 | Shows disk IO utilization and wait stats. | iostat -xz 1 3 |
lsof | grep deleted | Finds deleted files still held open by processes. | lsof | grep deleted |
Use cases: disk full, growing logs, deleted-but-still-open files, slow storage, container volume issues.
Memory
| Command | What it does | Example |
|---|---|---|
free -h | Shows RAM and swap usage in human-readable form. | free -h |
vmstat 1 5 | Shows memory, CPU and IO activity over time. | vmstat 1 5 |
top | Shows live process and memory usage. | top |
ps aux --sort=-%mem | head | Shows the highest memory-using processes. | ps aux --sort=-%mem | head |
pmap -x PID | tail -20 | Shows detailed memory map for a process. | pmap -x PID | tail -20 |
Use cases: RAM pressure, swap activity, large Java process, leak suspicion, runaway cache.
CPU
| Command | What it does | Example |
|---|---|---|
top | Shows live CPU usage by process. | top |
htop | Shows a more readable live CPU view. | htop |
mpstat -P ALL 1 3 | Shows CPU usage per core. | mpstat -P ALL 1 3 |
ps aux --sort=-%cpu | head | Shows the highest CPU-using processes. | ps aux --sort=-%cpu | head |
uptime | Shows system load averages and uptime. | uptime |
Use cases: high CPU, one hot core, thread contention, busy container, load spikes.
Fast Triage Sequence
- Check
uptimeandtop. - Check free disk with
df -h. - Check biggest directories with
du -sh *. - Check memory with
free -handvmstat. - Check per-core CPU with
mpstat -P ALL 1 3. - Check application process ownership of ports and files.