Detective mode: why is it so slow?
Every slow server has a suspect. Today you're the detective.
"The server is slow" is the most common complaint in IT. Today you'll cause the slowness yourself, then solve the case like a detective: CPU, memory and disk, one suspect at a time.
🧰 What you need
- A Linux machine you don't mind making very busy for a few minutes
Let's build it
Take a baseline
uptime
free -h
df -hLoad average, memory and disk space while things are calm. Detectives need a "before" picture.
Commit the crime
sudo apt install -y stress-ng htop
stress-ng --cpu 0 --timeout 300s &That keeps every CPU core flat out for five minutes, in the background.
Suspect #1: the CPU
htopAll the CPU bars are pinned, and stress-ng sits at the top. Press F6 to sort by something else and q to quit.
Arrest the culprit
pgrep -a stress-ng
pkill stress-ng
uptimeThe load average starts falling within a minute.
Suspect #2: the disk
fallocate -l 2G ~/big-mystery-file
df -h ~
sudo du -xh / 2>/dev/null | sort -h | tail -15du totals up folder sizes; sorted, the biggest folders sit at the bottom, and your home folder has suddenly grown by 2 GB.
Case closed
rm ~/big-mystery-file✅ How you know it worked
You can explain the slowness from evidence, not guesses: htop showed which process ate the CPU, and du showed which folder ate the disk.
💥 Break it on purpose
Run stress-ng --vm 1 --vm-bytes 90% --timeout 60s to attack memory instead, and watch the Mem and Swp bars in htop. When swap starts filling up, everything slows to a crawl, the classic "why is it so sluggish?" feeling.
🧠 What's really going on
Almost every slow Linux machine is short of one of three things: CPU (too much to compute), memory (so it swaps to slow disk) or disk (full, or too busy). The load average is the number of tasks waiting for their turn; if it's much higher than your number of CPU cores, work is queuing up. Tools like htop, free and df each shine a light on one suspect.
← Back to all Linux labs · Stuck? Email me