Unix top Command - Usage Guide
๐ What top Shows
When you run top, it displays:
1. System Summary
- uptime: How long the system has been running.
- users: Number of logged-in users.
- load average: 1, 5, and 15 minute load.
- Tasks: Total, running, sleeping processes, etc.
- CPU usage:
%us: user processes%sy: system/kernel processes%id: idle time%wa: I/O wait%hi: hardware interrupts%si: software interrupts%st: steal time (VMs)
- Memory and Swap: Total, used, free, buffers, etc.
2. Process List
Displays information per process:
PID: Process IDUSER: Owner%CPU: CPU usage%MEM: Memory usageTIME+: Total CPU time usedCOMMAND: Command name
๐ ️ Common Day-to-Day Usage in Production
- Find High CPU Usage: Use
Pto sort by CPU usage. - Check Memory Leaks: Use
Mto sort by memory usage. - Identify Stuck or Zombie Processes: Look for state
Z. - Check Load Averages: High load may indicate system stress.
- Check I/O Wait: High
%waindicates disk bottlenecks. - Kill a Misbehaving Process: Use
kand enter PID.
๐ง Useful Keybindings in top
| Key | Action |
|---|---|
P | Sort by CPU usage |
M | Sort by memory usage |
k | Kill a process (enter PID) |
R | Renice a process |
c | Toggle full command display |
1 | Show all CPU cores |
h | Help |
q | Quit |
๐งช Pro Tips
- Use
top -u <username>to filter by user. - Use
top -p <PID>to monitor a specific process. - Use
htopfor a more visual alternative (if installed).
No comments:
Post a Comment