Monitoring your server’s resource usage is crucial for maintaining performance, spotting potential issues early, and ensuring stability under load.
By keeping an eye on CPU, memory, disk, and network usage, you can quickly identify bottlenecks or misbehaving processes.
This guide covers the essential tools and techniques to monitor your Linux server effectively.
The top
command provides a live, real-time view of system processes and overall resource usage.
To use it:
Type:
top
Key outputs include CPU usage, memory usage, load averages, and the list of running processes.
Press "q" to quit.
htop
is a more user-friendly alternative to top
, displaying color-coded information and allowing easier navigation.
To install htop:
For Ubuntu/Debian:
sudo apt install htop
For CentOS/AlmaLinux/Rocky:
sudo dnf install htop
Then run:
htop
Use the arrow keys to navigate through processes.
Press "F10" to exit.
The free
command shows detailed information about RAM and swap memory usage.
Run:
free -h
The -h
flag displays values in human-readable format (MB/GB).
The df
command reports the amount of disk space used and available on file systems.
Run:
df -h
The -h
flag shows disk sizes in human-readable units.
To check how much space a particular directory is using, use:
du -sh /path/to/directory
The -s
flag summarizes total usage, and -h
makes the output readable.
The iostat
tool reports CPU load and disk I/O statistics.
Install it by installing the sysstat package:
For Ubuntu/Debian:
sudo apt install sysstat
For CentOS/AlmaLinux/Rocky:
sudo dnf install sysstat
Then run:
iostat
This shows CPU load and device I/O activity.
glances
provides a comprehensive overview of CPU, memory, disk I/O, network, and processes in a single screen.
Install glances:
For Ubuntu/Debian:
sudo apt install glances
For CentOS/AlmaLinux/Rocky:
sudo dnf install glances
Run it with:
glances
Glances automatically adapts the displayed information based on your terminal size.
To monitor network connections:
netstat
shows network statistics and open connections.
ss
is a faster, more modern alternative to netstat.
Example:
ss -tunap
This displays active TCP/UDP connections along with process information.
vmstat
reports information about processes, memory, paging, block I/O, traps, and CPU activity.
Run:
vmstat 2
This will update the statistics every 2 seconds.
If you want ongoing, graphical monitoring accessible via a browser, you can install tools like:
Netdata: Real-time performance monitoring with beautiful web dashboards.
Grafana + Prometheus: Advanced monitoring stack for long-term metrics storage and visualization.
Cockpit: A lightweight web-based server manager including resource monitoring.
These tools usually require more setup but provide powerful dashboards for larger environments.
Task | Command |
---|---|
Real-time process monitor | top or htop |
Check memory usage | free -h |
Check disk space | df -h |
Check specific folder usage | du -sh /path/to/directory |
CPU and disk I/O statistics | iostat |
Network connections | ss -tunap |
System performance stats | vmstat 2 |
All-in-one monitoring | glances |
Regularly monitoring your server helps catch problems before they affect users.
Set up alerts for critical metrics (like CPU, disk space, or RAM spikes) if possible.
Combine lightweight CLI tools with graphical dashboards for complete visibility on production servers.