Introduction
Monitoring a Linux server is an essential skill for developers, DevOps engineers, and system administrators. Whether you're hosting a web application, database, API, or microservice, understanding server health helps identify performance issues before they impact users.
Linux provides several built-in commands that allow you to monitor CPU usage, memory consumption, disk space, network activity, and running processes.
In this article, you'll learn the most important Linux monitoring commands every developer should know.
Why Server Monitoring Matters
A server may experience:
High CPU usage
Memory shortages
Disk space issues
Network bottlenecks
Application crashes
Without monitoring:
Issue Occurs
↓
Users Experience Problems
↓
Investigation StartsWith proper monitoring:
Issue Detected Early
↓
Quick ResolutionThis improves system reliability and uptime.
Check System Uptime
The uptime command shows how long the server has been running.
uptimeExample output:
10:30:15 up 25 days, 5:20,
load average: 0.35, 0.42, 0.50Useful information:
System uptime
Active users
Load averages
Monitor CPU and Processes
The top command provides real-time system monitoring.
topDisplays:
CPU usage
Memory usage
Running processes
System load
To exit:
qFor many developers, top is the first troubleshooting command.
Use htop for Better Visualization
If installed:
htopBenefits:
User-friendly interface
Color-coded metrics
Easy process management
Install on Ubuntu:
sudo apt install htopMany administrators prefer htop over top.
Check Memory Usage
View memory consumption:
free -hExample:
Total: 8GB
Used: 4GB
Free: 3GBThe -h flag displays human-readable values.
This command helps identify memory pressure.
Check Disk Space
Monitor disk usage:
df -hExample output:
Filesystem Size Used Avail
/dev/sda1 50G 20G 30GImportant for:
Application servers
Database servers
Log-heavy systems
Running out of disk space can cause service failures.
Find Large Directories
Identify storage-consuming folders.
du -sh *Example:
2G logs
500M backupsUseful when investigating disk usage issues.
Monitor Running Processes
View all running processes:
ps auxSearch for a specific application:
ps aux | grep nginxCommon use cases:
Verify services are running
Investigate high CPU usage
Troubleshoot applications
Monitor Network Connections
Check active network connections.
ss -tulnShows:
Listening ports
TCP connections
UDP connections
Useful for debugging connectivity issues.
Check Open Ports
View listening services:
netstat -tulnpExample:
Port 80
Port 443
Port 3306Helps verify web servers and databases are accessible.
View System Logs
Linux logs are essential for troubleshooting.
View recent logs:
journalctl -xeFor specific services:
journalctl -u nginxLogs often reveal the root cause of issues.
Monitor Disk I/O
Check disk activity:
iostatUseful for:
Database servers
File servers
Storage performance analysis
Install if needed:
sudo apt install sysstatReal-World Troubleshooting Example
Suppose your API becomes slow.
Investigation process:
top
↓
Check CPU
free -h
↓
Check Memory
df -h
↓
Check Disk
journalctl
↓
Check LogsUsing these commands together helps quickly identify the problem.
Best Practices
When monitoring Linux servers:
Check disk usage regularly.
Monitor CPU and memory trends.
Review logs frequently.
Set up alerting tools.
Investigate unusual spikes.
Remove unnecessary processes.
These habits help maintain healthy systems.
Conclusion
Linux provides powerful built-in tools for monitoring server health and diagnosing performance issues. Commands such as top, htop, free, df, ps, ss, and journalctl give developers valuable insight into system behavior.
Whether you're managing web applications, APIs, databases, or cloud servers, understanding these commands will help you troubleshoot problems faster and maintain reliable systems. Mastering Linux monitoring is a foundational skill for every developer working with production environments.


Join the conversation! Your thoughts help the community grow.