Chapter 26: System Monitoring
What is System Monitoring? (super simple first)
System monitoring means watching and checking how your Linux computer (or server) is working right now and over time.
You keep an eye on important things like:
- CPU → how busy is the brain of your computer?
- Memory (RAM) → is it full? Is something eating too much?
- Disk → how much space left? Is reading/writing slow?
- Network → how much internet/download/upload is happening?
- Processes → which programs are running? Any zombie or hung ones?
- Temperature (laptops/servers) → is it getting too hot?
- Logs & errors → any crashes, warnings, failed logins?
Why do we do this?
- Catch problems before they crash your system (e.g. RAM full → slow → freeze)
- Find why something is slow (e.g. one bad app using 100% CPU)
- Know when to buy more RAM / upgrade server
- Debug why website/app is slow for users
- Security: spot strange high network or unknown processes
In short: It’s like checking your phone battery + temperature + apps running when it starts lagging.
Linux gives you tons of free built-in commands and nice tools for this – no need to install anything at first!
Main Things We Monitor (the big 5)
- CPU – load average (1 min, 5 min, 15 min), % used per core
- Memory – used / free / cached / swap
- Disk – space used, I/O speed (read/write speed)
- Network – bandwidth in/out, connections
- Processes – top CPU/memory eaters, number running
1. The Classic – top (start here – try now!)
|
0 1 2 3 4 5 6 |
top |
What you see:
- Top lines: load average (e.g. 0.85 0.60 0.45) → lower is better
- %Cpu(s): us (user), sy (system), id (idle) → high id = good
- MiB Mem / Swap: total, free, used
- Tasks: total, running, sleeping, zombie
- List of processes: PID, USER, %CPU, %MEM, COMMAND
Useful keys inside top:
- q → quit
- 1 → show each CPU core separately
- Shift + P → sort by CPU
- Shift + M → sort by memory
- k → kill process (type PID)
- f → manage fields (add/remove columns)
Most people start with top → then move to better versions.
2. Better than top – htop (install & love it)
|
0 1 2 3 4 5 6 7 8 9 10 |
sudo apt install htop # Ubuntu/Debian # or sudo dnf install htop # Fedora # or sudo pacman -S htop # Arch htop |
Why better?
- Colors! Mouse support!
- Scroll with arrows/mouse
- Tree view (F5) – see child processes
- Kill easily (F9)
- Search process (F3)
- Setup columns (F2)
Try: run htop → press F2 → Colors → choose nice scheme.
3. Modern & pretty ones (2026 favorites)
Install one of these – very popular now:
|
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
# btop++ (beautiful dashboard) sudo apt install btop # or from github if not in repo btop # glances (all-in-one, web mode too!) sudo apt install glances glances # or run in web mode: glances -w → open browser http://localhost:61208 |
btop looks like a game dashboard – CPU bars, graphs for disk/net.
4. Quick one-line checks (no install needed)
CPU quick look:
|
0 1 2 3 4 5 6 7 8 9 |
uptime # load averages + users cat /proc/loadavg # same lscpu | grep -i mhz # current CPU speed |
Memory:
|
0 1 2 3 4 5 6 7 |
free -h # human readable (-h) # Mem: total used free shared buff/cache available |
Disk space:
|
0 1 2 3 4 5 6 7 |
df -h # disk free -h du -sh ~/* # what's taking space in home |
Disk speed / activity:
|
0 1 2 3 4 5 6 |
iostat -x 1 5 # install sysstat: sudo apt install sysstat |
Network:
|
0 1 2 3 4 5 6 7 |
ip -s link # bytes in/out per interface ss -s # socket summary |
Processes:
|
0 1 2 3 4 5 6 7 |
ps aux | head -15 # top 15 processes ps -eo pid,ppid,%cpu,%mem,cmd --sort=-%cpu | head |
5. Live watching (very useful for debugging)
|
0 1 2 3 4 5 6 7 8 9 10 |
watch -n 2 free -h # update every 2 seconds watch -n 1 "df -h /" # watch root disk # Or combine watch -n 1 "uptime && free -h && df -h /" |
6. Quick cheat-sheet table (save this!)
| What to check | Best command | What it tells you |
|---|---|---|
| Quick overview | top or htop | CPU, RAM, processes live |
| Load average | uptime | 1/5/15 min system busyness |
| Memory usage | free -h | Total/used/free RAM + swap |
| Disk space | df -h | % used per partition |
| Big folders/files | du -sh ~/* |
sort -hr |
| CPU per core | mpstat 1 5 (sysstat) | Detailed CPU stats |
| Disk I/O speed | iostat -x 1 | Read/write KB/s, %util |
| Network connections | ss -tuln or netstat -tuln | Listening ports + connections |
| Pretty dashboard | btop or glances | Graphs + colors (modern feel) |
| Temperature (laptop) | sensors (lm-sensors package) | CPU/GPU temp |
7. Real-life examples (Hyderabad developer style)
- Your web app slow? → htop → see if Node/Python using 100% CPU
- Server full disk? → df -h → find big /var/log or /home
- Laptop hot & fan loud? → watch sensors → see temp rise
- New server setup? → uptime; free -h; df -h; lscpu → quick health check
- Debugging high traffic? → iftop or nethogs → who eating bandwidth
Practice right now:
- Open terminal
- Type top → look around → press 1 → q
- Install & run htop
- Run free -h and df -h
- Run watch -n 2 uptime
Tell me what your load average is right now (e.g. 0.45 0.30 0.25) or what process is using most CPU!
Or ask:
- “How to monitor temperature on my laptop?”
- “Best tool for network bandwidth live?”
- “How to set alerts if CPU > 90%?”
We’ll go deeper together! 😄
