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

CommandWhat it doesExample
df -hShows 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 +100MFinds very large log files.find /var/log -type f -size +100M
iostat -xz 1 3Shows disk IO utilization and wait stats.iostat -xz 1 3
lsof | grep deletedFinds 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

CommandWhat it doesExample
free -hShows RAM and swap usage in human-readable form.free -h
vmstat 1 5Shows memory, CPU and IO activity over time.vmstat 1 5
topShows live process and memory usage.top
ps aux --sort=-%mem | headShows the highest memory-using processes.ps aux --sort=-%mem | head
pmap -x PID | tail -20Shows 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

CommandWhat it doesExample
topShows live CPU usage by process.top
htopShows a more readable live CPU view.htop
mpstat -P ALL 1 3Shows CPU usage per core.mpstat -P ALL 1 3
ps aux --sort=-%cpu | headShows the highest CPU-using processes.ps aux --sort=-%cpu | head
uptimeShows system load averages and uptime.uptime

Use cases: high CPU, one hot core, thread contention, busy container, load spikes.

Fast Triage Sequence

  1. Check uptime and top.
  2. Check free disk with df -h.
  3. Check biggest directories with du -sh *.
  4. Check memory with free -h and vmstat.
  5. Check per-core CPU with mpstat -P ALL 1 3.
  6. Check application process ownership of ports and files.