>Usage
The top command is a utility used to display real-time information about system processes and resource usage. It provides a dynamic, constantly updated view of system performance, including CPU usage, memory usage, and process details. It is useful for monitoring and troubleshooting system performance in real time. Press q to exit.
>Synopsis
>Options
-o [key]
Sorts the output by a specific column (e.g., cpu, mem, etc.).
Example 1:
-zsh
>top -o cpu
PID COMMAND %CPU TIME #TH #WQ #PORTS MEM PURG CMPRS PGRP
1540 WindowServer 13.3 10:11:32 21 6 3266 1005M 452M+ 272M 1540
37050 Terminal 5.8 01:22.50 9 2 406 290M+ 172M+ 56M- 37050
41712 top 5.2 00:00.93 1/1 0 27 7297K 0B 0B 41712
0 kernel_task 5.2 07:26:33 580/11 0 0 2010M 0B 0B 0
38648 com.apple.We 0.3 04:05.78 4 1 81- 347M- 0B 15M 38648
1486 powerd 0.1 13:00.38 3 2 148 5665K 0B 944K 1486
1890 pboard 0.0 00:03.90 3 2 208+ 4129K+ 0B 784K 1890
1536 corebrightne 0.0 14:47.80 3 2 133 5393K 0B 2176K 153
-n [number]
Limits the display to the specified number of processes.
Example 2:
-zsh
>top -n 3
ID COMMAND %CPU TIME #TH #WQ #PORT MEM PURG CMPR PGRP
1540 WindowServer 18.7 10:12:01 20 4 3269 1005M- 592M+ 268M 1540
37050 Terminal 8.0 01:24.09 10 3 411 291M- 172M+ 55M- 37050
0 kernel_task 6.7 07:26:43 580/11 0 0 2010M 0B 0B 0
-stats
Specifies which columns to display in the output.
Example 3:
-zsh
>top -stats pid,cpu,command
PID %CPU COMMAND
41720 4.7 top
0 1.9 kernel_task
1540 1.0 WindowServer
37050 0.4 Terminal
1869 0.3 distnoted
1484 0.2 configd
1524 0.1 distnoted
38648 0.1 com.apple.WebKit
1558 0.1 airportd
-u
Displays only processes owned by the current user.
Example 4:
-zsh
>top -u
PID COMMAND %CPU TIME #TH #WQ #PORTS MEM PURG CMPRS PGRP
1540 WindowServer 9.6 10:12:44 20 4 3269 1005M- 446M+ 267M 1540
41723 top 5.6 00:04.12 1/1 0 29 7217K 0B 0B 41723
0 kernel_task 4.8 07:26:58 580/11 0 0 2010M 0B 0B 0
37050 Terminal 3.9 01:26.40 12 5 411 291M- 172M+ 54M- 37050
2000 imagent 1.5 02:17.54 4 3 172 9553K 0B 2688K 2000