Problem Statement
What does the top command do?
Explanation
Top provides a dynamic, real-time view of running processes and system resource usage. It updates every few seconds showing CPU usage, memory usage, swap usage, running processes sorted by resource consumption. The top section shows system summary including uptime, load average, total/running/sleeping/stopped processes, and CPU/memory statistics.
Interactive commands within top include: k to kill processes, r to renice (change priority), M to sort by memory usage, P to sort by CPU usage, u to filter by user, c to show full command paths, and q to quit. Use top -u username to show processes for specific user, or top -p PID1,PID2 to monitor specific processes.
Top is invaluable for performance monitoring, identifying resource bottlenecks, finding runaway processes, and troubleshooting performance issues. Alternatives include htop (more user-friendly with colors and mouse support) and atop (advanced metrics). Understanding top is essential for system administrators and DevOps engineers managing Linux servers.
Practice Sets
This question appears in the following practice sets:
