Linux - top & htop in Linux
What is top?
top is a default, command-line system monitor in Linux that displays real-time information about:
-
CPU usage
-
Memory usage
-
Running processes
-
Load average
-
Swap usage
-
Process IDs, states, priorities
How it looks
It opens inside the terminal and updates every 3 seconds by default.
Key Use Cases
-
Identify processes consuming high CPU/RAM
-
Monitor load average
-
Kill or renice processes
Useful Keys in top:
| Key | Action |
|---|---|
| P | Sort by CPU usage |
| M | Sort by Memory usage |
| k | Kill a process |
| r | Renice (change priority) |
| q | Quit |
2️⃣ What is htop?
htop is a modern, interactive, user-friendly system monitor — an improved version of top.
It has:
-
Colorful display
-
Graphs for CPU, memory, swap
-
Scrollable list of processes
-
Mouse support
-
Easier process killing and sorting
Why users prefer htop:
✔ Better UI
✔ Easier navigation
✔ Search option
✔ Shows full command paths
✔ Color-coded resource usage
Install htop
3️⃣ Key Differences (top vs htop)
| Feature | top | htop |
|---|---|---|
| Interface | Basic, text-only | Colorful, interactive |
| Navigation | Keyboard only | Keyboard + mouse |
| Process list | Not scrollable | Scrollable |
| Sorting | Manual keys (P, M) | One-click / function keys |
| CPU/Mem Graphs | No | Yes |
| Kill process | Press k | Press F9 (menu) |
| Full command line | Not always visible | Always visible |
| Install | Comes pre-installed | Needs installation |
Summary: