Understanding Linux Process Management: ps, top, and htop

When a Linux box is running slow, the answer is almost always visible in its process table — you just need to know how to look. These three tools cover 95% of everyday process troubleshooting.

ps: A Point-in-Time Snapshot

# The classic combo: all processes, full format, for every user
ps aux

# Sort by memory usage, top 10
ps aux --sort=-%mem | head -11

# Find a specific process by name
ps aux | grep nginx

top: Live, Continuously Updating View

top refreshes in place and is the fastest way to see what’s consuming CPU or memory right now. Key interactive commands: M sorts by memory, P sorts by CPU, k kills a process by PID, q quits.

htop: The Friendlier Successor

sudo apt install htop
htop

htop adds color, mouse support, a tree view of parent/child process relationships (t), and per-core CPU graphs — genuinely nicer for interactive use, though top remains the one guaranteed to be pre-installed on literally every Linux system you’ll ever SSH into.

Understanding Process States

  • R — Running or runnable
  • S — Sleeping, waiting for an event
  • D — Uninterruptible sleep, usually waiting on disk I/O (a lot of D-state processes is a red flag for storage problems)
  • Z — Zombie, finished but not yet reaped by its parent

A machine full of D-state processes points at disk trouble; a machine full of Z-state zombies points at a parent process that’s failing to call wait() on its children — two very different problems that look similar at a glance but need completely different fixes.