When managing Linux systems, monitoring performance is essential to ensure everything runs smoothly. Tools like htop
and glances
make it easier to track CPU, memory, processes, and overall system health.
This guide covers:
- Why you need system monitoring tools.
- Installing
htop
andglances
. - How to use these tools effectively.
1. Why Use htop
and glances
?
While the default top
command provides system stats, it can be limited in readability and features.
htop
: A modern, interactive, and user-friendly alternative totop
. It offers a real-time, color-coded view of system processes.glances
: A more comprehensive, cross-platform tool that displays CPU, memory, network, and disk usage in a single, unified interface.
Both tools make performance monitoring quick, visual, and efficient.
2. Installing htop
and glances
Install htop
-
On Debian/Ubuntu:
sudo apt update sudo apt install htop
-
On CentOS/RHEL:
sudo yum install epel-release sudo yum install htop
-
On Arch Linux:
sudo pacman -S htop
Run htop
to start:
htop
Install glances
glances
requires Python, so you can install it using pip
or your package manager.
-
Using pip (cross-platform):
pip install glances
-
On Debian/Ubuntu:
sudo apt update sudo apt install glances
-
On CentOS/RHEL:
sudo yum install glances
Run glances
to start:
glances
3. How to Use htop
Launch htop
Run htop
from the terminal:
htop
Key Features of htop
:
-
Color-coded stats:
- Green = User CPU usage
- Red = System CPU usage
- Blue = I/O wait
-
Interactive Controls:
- Scroll with arrow keys.
- Kill processes: Press
F9
. - Sort processes: Press
F6
to choose a sorting method (e.g., CPU, memory). - Search for processes: Press
/
and type the process name.
Quick Shortcut Summary
Action | Key |
---|---|
Scroll through list | Arrow keys |
Kill a process | F9 |
Sort processes | F6 |
Search processes | / |
Quit htop |
q |
4. How to Use glances
Launch glances
Run glances
from the terminal:
glances
Key Features of glances
:
- Unified Dashboard: Displays CPU, memory, network, disk usage, and more.
- Auto-refresh: Real-time updates with minimal resource usage.
- Interactive Controls:
- Toggle views: Press
1
,2
, or3
for detailed CPU stats. - Quit: Press
q
.
- Toggle views: Press
Glances in Web Mode
Run glances
as a web service to monitor remotely:
glances -w
Then access it in a browser:
http://your-server-ip:61208
5. Which Tool Should You Use?
Feature | htop | glances |
---|---|---|
Ease of Use | Simple, process-focused | Unified, detailed dashboard |
Installation | Lightweight, fast setup | Requires Python, more tools |
Remote Monitoring | No | Yes (glances -w ) |
System Stats | CPU, memory, processes | CPU, memory, disk, network, etc. |
- Use
htop
for quick, interactive process management. - Use
glances
for a broader system overview, especially for servers.
Conclusion
Both htop
and glances
are powerful tools for monitoring Linux systems. If you’re managing servers or troubleshooting performance, these tools are invaluable for gaining real-time insights.
- Start with
htop
for simplicity. - Explore
glances
for deeper system monitoring.