Understanding the 'top' Command
The top
command is a powerful tool in the Linux operating system that provides real-time information about the running processes on a system. It displays a dynamic, continuously updating list of the most resource-intensive processes, along with various system-level metrics such as CPU, memory, and swap usage.
What is the 'top' Command?
The top
command is a command-line utility that allows users to monitor system performance and resource utilization. It provides a comprehensive overview of the running processes, their resource consumption, and various system-level statistics.
Usage of the 'top' Command
To use the top
command, simply open a terminal and type top
. This will display the default view of the top
command, which includes the following information:
- Process ID (PID)
- User running the process
- CPU utilization
- Memory usage
- Time the process has been running
- Command name
Users can interact with the top
command using various keyboard shortcuts and commands to customize the display, sort the processes, and perform other actions.
Example Usage
Here's an example of using the top
command on an Ubuntu 22.04 system:
$ top
top - 14:23:32 up 1 day, 12:34, 1 user, load average: 0.00, 0.01, 0.05
Tasks: 159 total, 1 running, 158 sleeping, 0 stopped, 0 zombie
%Cpu(s): 0.0 us, 0.3 sy, 0.0 ni, 99.7 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
KiB Mem : 8048996 total, 5202380 free, 905736 used, 1940880 buff/cache
KiB Swap: 2097148 total, 2097148 free, 0 used. 6389300 avail Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
1 root 20 0 172624 11620 8220 S 0.0 0.1 0:03.42 systemd
2 root 20 0 0 0 0 S 0.0 0.0 0:00.02 kthreadd
3 root 20 0 0 0 0 I 0.0 0.0 0:00.01 rcu_gp
This output provides a comprehensive overview of the system's current state, including CPU, memory, and swap usage, as well as a list of the running processes and their resource consumption.