top is an essential utility that provides real-time information about system performance and running processes. The top command displays system statistics, including CPU and memory usage, and provides a detailed list of running processes with various metrics.
Basic Syntax
top [options]
Commonly Used Options
-
-d: Set the delay between updates (in seconds). -
-p: Monitor specific process IDs. -
-u: Monitor processes owned by a specific user. -
-k: Set the sort order for the displayed list of processes. -
-b: Run in batch mode (useful for logging to a file). -
-n: Set the number of iterations to run before exiting. -
-H: Show individual threads for each process. -
-i: Don’t display idle processes. -
-c: Show absolute path of the process command.
Examples of Using top Options
-
top: Displays a continuously updating list of running processes and system performance metrics, sorted by CPU usage by default. -
top -d 5: Displays a continuously updating list of running processes and system performance metrics, with a 5 second delay between updates. -
top -u username: Displays a continuously updating list of running processes and system performance metrics, showing only processes owned by the specified user. -
top -p pid: Displays a continuously updating list of running processes and system performance metrics, showing only the process with the specified process ID. -
top -o %MEM: Displays a continuously updating list of running processes and system performance metrics, sorted by memory usage (with the highest usage at the top of the list). -
top -H: Displays a continuously updating list of running processes and system performance metrics, showing individual threads for each process. -
top -i: Displays a continuously updating list of running processes and system performance metrics, with idle processes hidden. -
top -c: Displays a continuously updating list of running processes and system performance metrics, showing the absolute path of the process command.
Displayed Metrics in top
-
PID: The unique process ID. -
USER: The user who started the process. -
%CPU: The percentage of CPU time the process has used. -
%MEM: The percentage of physical memory the process has used. -
RES: The resident set size (i.e., the amount of physical memory) the process is using. -
VIRT: The virtual memory size of the process. -
SHR: The amount of shared memory used by the process. -
TIME+: The total CPU time the process has used. -
COMMAND: The command used to start the process.
Leave a Reply