Linux System Monitoring Commands
Linux system monitoring helps administrators understand CPU usage, memory consumption, system load, running processes, and overall server health. Command-line monitoring tools make it easier to identify performance problems before they affect applications.
Why is Linux System Monitoring Important?
A Linux server can experience high CPU usage, low memory, excessive disk activity, or overloaded processes. Monitoring provides useful information for diagnosing these issues and understanding how system resources are being used.
Monitor CPU → Check Memory → Inspect Processes → Check Load → Identify Bottleneck → Take Action
Checking System Uptime
The uptime command shows how long the system has been running and provides the current system load averages.
uptime
Monitoring CPU and Processes with top
The top command provides a real-time overview of running processes, CPU usage, memory usage, and system load.
top
Checking Memory with free
The free command displays information about physical memory, available memory, swap, and memory usage.
free -h
Using vmstat
The vmstat command reports information about processes, memory, paging, block I/O, and CPU activity. It can be useful for getting a broader view of system performance.
vmstat
vmstat 2 5
Checking CPU Information
The lscpu command displays information about the system processor, including CPU architecture, cores, threads, and supported features.
lscpu
Checking Memory Information
The /proc/meminfo file contains detailed information about memory usage and memory-related statistics maintained by the Linux kernel.
cat /proc/meminfo
head /proc/meminfo
Checking System Load
Load averages provide an indication of how much work is waiting for or using CPU resources. They are commonly displayed by uptime and top.
uptime
cat /proc/loadavg
Linux Monitoring Command Table
| Command | Purpose | Example |
|---|---|---|
| uptime | Check uptime and load average | uptime |
| top | Monitor processes and resources | top |
| free | Check memory usage | free -h |
| vmstat | Monitor system performance | vmstat 2 5 |
| lscpu | Display CPU information | lscpu |
| cat /proc/meminfo | View detailed memory statistics | cat /proc/meminfo |
Example Troubleshooting Scenario
Slow Server → uptime → top → free -h → vmstat → Identify CPU/Memory Bottleneck → Investigate Process
Common Performance Problems
- High CPU utilization
- Insufficient available memory
- Excessive swap usage
- Too many running processes
- High system load
- Heavy I/O activity
Useful Monitoring Practices
- Monitor resource usage regularly
- Track unusual CPU spikes
- Check memory and swap usage
- Identify resource-heavy processes
- Compare current usage with normal workloads
Common Mistakes to Avoid
- Judging server health from CPU usage alone
- Ignoring memory and swap activity
- Killing processes without investigation
- Ignoring long-term performance trends
- Making configuration changes without measuring results
Advanced Linux Monitoring Concepts
- Performance monitoring
- System load analysis
- Process accounting
- I/O monitoring
- Kernel statistics
- Resource monitoring with cgroups
Practice Exercises
- Check system uptime and load average
- Monitor processes using top
- Check available memory
- Display CPU information
- Monitor system statistics with vmstat
- Identify the process using the most CPU
Conclusion
Linux monitoring commands provide valuable information about system health and resource usage. Tools such as uptime, top, free, vmstat, and lscpu help administrators identify performance bottlenecks and troubleshoot Linux servers efficiently.