📈 Checking System Performance
Think of your Linux system like a busy office. You have employees (CPU cores), storage shelves (RAM), and ongoing tasks (processes). Monitoring performance is like checking how busy each employee is, if any shelf is overflowing, or if tasks are getting stuck. We'll go command by command.
top – The "Live Dashboard"
This command shows all running processes, CPU & memory usage, and system load in real-time.
Press q to quit.
Key things to notice:
- CPU usage → %us (user tasks), %sy (system tasks), %id (idle)
- Memory usage → Total, used, free, buffers/cache
- Processes → PID, user, CPU%, MEM%, command
htop – The Fancy Interactive Version
This command is like top but prettier, colored, and interactive.
Use arrow keys to navigate, F10 to quit. (Tip: Some systems may require sudo apt install htop first.)
Features:
- Scroll through processes
- Kill processes directly from interface
- Sort by CPU, memory, or runtime
free – Memory Snapshot
This command shows RAM and swap usage instantly.
Output columns:
- total → total RAM
- used → RAM in use
- free → RAM not used
- shared → memory shared between programs
- buffers/cache → memory temporarily used by system
- available → RAM actually available for new tasks
vmstat – The Performance Reporter
This command gives a quick overview of CPU, memory, and I/O stats over time.
This prints stats every 2 seconds, 5 times.
Key columns:
- r → number of processes waiting for CPU
- b → processes in uninterruptible sleep
- swpd → used swap
- free → free memory
- us, sy, id → CPU usage by user, system, idle
Practical Tip
If your system feels slow:
- Use top or htop to see which processes are hogging CPU/memory.
- Use free to check if RAM is full (swap being used heavily is a bad sign).
- Use vmstat for spotting repeated CPU/memory spikes over time.
Real-life analogy
For top: Imagine a digital scoreboard in your office showing what every employee is doing right now, who's overloaded, and who's idle. For htop: Imagine top got a modern touchscreen dashboard where you can scroll, filter, and sort tasks easily. For free: Like checking your office's storage shelves: how full are they, how much is free, and how much is borrowed from backup storage (swap)? For vmstat: Like a manager's report showing how employees, storage, and deliveries performed every few seconds. This is your first layer of system monitoring — like checking the pulse of your computer.