top Command: Tutorial & Examples
Display the top running processes
The top
command is a real-time system monitoring tool that displays a dynamic view of the system's processes and resource usage. It shows a list of the currently running processes, along with information about their CPU and memory usage, priority, and other details.
To start top
, simply type top at the command prompt. By default, top updates the display every few seconds and sorts the process list by CPU usage.
top
Here is an example of the top command's output:
top - 13:46:57 up 150 days, 4:03, 11 users, load average: 3.75, 3.95, 3.54
Tasks: 307 total, 1 running, 306 sleeping, 0 stopped, 0 zombie
%Cpu(s): 7.8 us, 0.8 sy, 0.0 ni, 91.0 id, 0.1 wa, 0.0 hi, 0.3 si, 0.0 st
MiB Mem : 64305.6 total, 999.9 free, 41519.1 used, 21786.5 buff/cache
MiB Swap: 3796.0 total, 1856.5 free, 1939.5 used. 22067.4 avail Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
8165 mysql 20 0 983.1g 33.8g 8044 S 105.0 53.9 567144:43 mysqld
16058 root 20 0 6437408 466308 8096 S 9.6 0.7 5411:24 java
791477 root 20 0 6692620 313092 17928 S 6.0 0.5 36:58.26 java
2605714 root 20 0 10.7g 1.2g 12996 S 6.0 2.0 967:52.13 java
2520408 root 20 0 5893648 342000 11952 S 4.0 0.5 599:09.46 java
914650 root 20 0 7110816 1.2g 8404 S 2.0 1.9 39952:51 java
3050519 root 20 0 13236 8196 6220 S 2.0 0.0 806:16.58 ssh
13850 root 20 0 4963988 328148 16588 S 1.7 0.5 66:15.43 java
933092 root 20 0 7438060 476816 2484 S 1.0 0.7 2755:54 java
889630 root 20 0 0 0 0 I 0.3 0.0 0:00.05 kworker/u64:15-kcryptd/253:0
890189 root 20 0 10180 3980 3248 R 0.3 0.0 0:00.02 top
As you can see, the mysql
process is the first in the list as is uses the most CPU time. It also uses about half of the available RAM.