Top Command Basics
What is the Top Command?
The top
command is a powerful built-in utility in Linux systems that provides real-time dynamic view of running processes. It offers system administrators and developers a comprehensive overview of system resource utilization, CPU usage, memory consumption, and process management.
Key Features of Top Command
Process Monitoring
- Displays active processes in real-time
- Shows CPU and memory usage for each process
- Provides detailed system performance metrics
Resource Tracking
- Monitors system load average
- Tracks memory and swap space usage
- Identifies resource-intensive processes
Basic Syntax and Usage
top [options]
Common Options
Option |
Description |
-d |
Set refresh interval |
-n |
Specify number of iterations |
-p |
Monitor specific process ID |
-u |
Filter processes by user |
Interactive Modes
graph TD
A[Top Command Launched] --> B{Interactive Mode}
B --> |Press 'h'| C[Help Screen]
B --> |Press 'k'| D[Kill Process]
B --> |Press 'q'| E[Quit Top]
Sample Top Command Output
top - 14:30:22 up 2:45, 3 users, load average: 0.75, 0.80, 0.85
Tasks: 250 total, 3 running, 247 sleeping
%Cpu(s): 15.5 us, 5.2 sy, 0.0 ni, 79.3 id
MiB Mem : 16384.0 total, 8192.0 free, 4096.0 used
Best Practices
- Use
top
for real-time system monitoring
- Identify performance bottlenecks
- Monitor resource-intensive processes
- Troubleshoot system performance issues
LabEx recommends practicing top
command in controlled environments to understand system dynamics effectively.