ArunNetworkingPro
🔍

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.

Intermediate1 eveningTroubleshooting
CPUMEMDISK🔥🕵️aha... stress-ng!

🧰 What you need

Let's build it

1

Take a baseline

uptime
free -h
df -h

Load average, memory and disk space while things are calm. Detectives need a "before" picture.

2

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.

3

Suspect #1: the CPU

htop

All the CPU bars are pinned, and stress-ng sits at the top. Press F6 to sort by something else and q to quit.

4

Arrest the culprit

pgrep -a stress-ng
pkill stress-ng
uptime

The load average starts falling within a minute.

5

Suspect #2: the disk

fallocate -l 2G ~/big-mystery-file
df -h ~
sudo du -xh / 2>/dev/null | sort -h | tail -15

du totals up folder sizes; sorted, the biggest folders sit at the bottom, and your home folder has suddenly grown by 2 GB.

6

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