1.Dd April 1, 2025 2.Dt TOP 1 3.Os 4.Sh NAME 5.Nm top 6.Nd display and update information about the top cpu processes 7.Sh SYNOPSIS 8.Nm 9.Op Fl abCHIijnPqSTtuvwz 10.Op Fl d Ar count 11.Op Fl J Ar jail 12.Op Fl m Ar cpu | io 13.Op Fl o Ar field 14.Op Fl p Ar pid 15.Op Fl s Ar time 16.Op Fl U Ar username 17.Op Ar number 18.Sh DESCRIPTION 19.Nm 20displays the top 21processes on the system and periodically updates this information. 22If standard output is an intelligent terminal (see below) then 23as many processes as will fit on the terminal screen are displayed 24by default. 25Otherwise, a good number of them are shown (around 20). 26Raw cpu percentage is used to rank the processes. 27If 28.Ar number 29is given, then the top 30.Ar number 31processes will be displayed instead of the default. 32.Pp 33.Nm 34makes a distinction between terminals that support advanced capabilities 35and those that do not. 36This distinction affects the choice of defaults for certain options. 37In the remainder of this document, an 38.Dq intelligent 39terminal is one that 40supports cursor addressing, clear screen, and clear to end of line. 41Conversely, a 42.Dq dumb 43terminal is one that does not support such 44features. 45If the output of 46.Nm 47is redirected to a file, it acts as if it were being run on a dumb 48terminal. 49.Pp 50The options are as follows: 51.Bl -tag -width indent 52.It Fl a 53Display command names derived from the argv[] vector, rather than real 54executable name. 55It it useful when you want to watch applications, that 56puts their status information there. 57If the real name differs from argv[0], 58it will be displayed in parenthesis. 59Non-printable characters in the command line are 60encoded in C-style backslash sequences or 61a three digit octal sequences. 62.It Fl b 63Use 64.Dq batch 65mode. 66In this mode, all input from the terminal is 67ignored. 68Interrupt characters (such as ^C and ^\e) still have an effect. 69This is the default on a dumb terminal, or when the output is not a terminal. 70.It Fl C 71Toggle CPU display mode. 72By default top displays the weighted CPU percentage in the WCPU column 73(this is the same value that 74.Xr ps 1 75displays as CPU). 76Each time 77.Fl C 78flag is passed it toggles between 79.Dq raw cpu 80mode and 81.Dq weighted cpu 82mode, showing the 83.Dq CPU 84or the 85.Dq WCPU 86column respectively. 87.It Fl d Ar count 88Show only 89.Ar count 90displays, then exit. 91A display is considered to be one update of the 92screen. 93The default is 1 for dumb terminals. 94Note that for 95.Ar count 96= 1 97no information is available about the percentage of time spent by the CPU in every state. 98.It Fl H 99Display each thread for a multithreaded process individually. 100By default a single summary line is displayed for each process. 101.It Fl I 102Do not display idle processes. 103By default, top displays both active and idle processes. 104.It Fl i 105Use 106.Dq interactive 107mode. 108In this mode, any input is immediately 109read for processing. 110See the section on 111.Dq Interactive Mode 112for an explanation of 113which keys perform what functions. 114After the command is processed, the 115screen will immediately be updated, even if the command was not 116understood. 117This mode is the default when standard output is an 118intelligent terminal. 119.It Fl J Ar jail 120Show only those processes owned by 121.Ar jail . 122This may be either the 123.Ar jid 124or 125.Ar name 126of the jail. 127Use 1280 129to limit to host processes. 130Using this option implies 131.Fl j . 132.It Fl j 133Display the 134.Xr jail 8 135ID. 136.It Fl m Ar mode 137Display statistics in the specified 138.Ar mode . 139Available modes are 140.Cm cpu 141and 142.Cm io . 143Default is 144.Cm cpu . 145.It Fl n 146Use 147.Dq non-interactive 148mode. 149This is identical to 150.Dq batch 151mode. 152.It Fl o Ar field 153Sort the process display area on the specified field. 154The field name 155is the name of the column as seen in the output, but in lower case: 156.Dq cpu , 157.Dq size , 158.Dq res , 159.Dq time , 160.Dq pri , 161.Dq threads , 162.Dq total , 163.Dq read , 164.Dq write , 165.Dq fault , 166.Dq vcsw , 167.Dq ivcsw , 168.Dq jid , 169.Dq swap , 170or 171.Dq pid . 172.It Fl P 173Display per-cpu CPU usage statistics. 174.It Fl p Ar pid 175Show only the process 176.Ar pid . 177.It Fl q 178Renice 179.Nm 180to -20 so that it will run faster. 181This can be used when the system is 182being very sluggish to improve the possibility of discovering the problem. 183This option can only be used by root. 184.It Fl S 185Show system processes in the display. 186Normally, system processes such as the pager and the swapper are not shown. 187This option makes them visible. 188.It Fl s Ar time 189Set the delay between screen updates to 190.Ar time 191seconds, which may be fractional. 192The default delay between updates is 1 second. 193.It Fl T 194Toggle displaying thread ID (tid) instead of process id (pid). 195.It Fl t 196Do not display the 197.Nm 198process itself. 199.It Fl U Ar username 200Show only those processes owned by 201.Ar username . 202This option currently only accepts usernames and will not understand 203uid numbers. 204.It Fl u 205Do not map uid numbers to usernames. 206Normally, 207.Nm 208will read as much of the file 209.Pa /etc/passwd 210as is necessary to map 211all the user id numbers it encounters into login names. 212This option disables all that, while possibly decreasing execution time. 213The uid numbers are displayed instead of the names. 214.It Fl v 215Write version number information to stderr then exit immediately. 216.It Fl w 217Display approximate swap usage for each process. 218.It Fl z 219Do not display the system idle process. 220.El 221.Pp 222Both 223.Ar count 224and 225.Ar number 226fields can be specified as 227.Dq infinite , 228indicating that they can 229stretch as far as possible. 230This is accomplished by using any proper 231prefix of the keywords 232.Dq infinity , 233.Dq maximum , 234or 235.Dq all . 236Boolean flags are toggles. 237A second specification of any of these options will negate the first. 238.Sh INTERACTIVE MODE 239When 240.Nm 241is running in 242.Dq interactive mode , 243it reads commands from the 244terminal and acts upon them accordingly. 245In this mode, the terminal is 246put in 247.Dq CBREAK , 248so that a character will be 249processed as soon as it is typed. 250Almost always, a key will be 251pressed when 252.Nm 253is between displays; that is, while it is waiting for 254.Ar time 255seconds to elapse. 256If this is the case, the command will be 257processed and the display will be updated immediately thereafter 258.Pq reflecting any changes that the command may have specified . 259This happens even if the command was incorrect. 260If a key is pressed while 261.Nm 262is in the middle of updating the display, it will finish the update and 263then process the command. 264Some commands require additional information, 265and the user will be prompted accordingly. 266While typing this information 267in, the user's erase and kill keys (as set up by the command 268.Xr stty 1 ) 269are recognized, and a newline terminates the input. 270.Pp 271The bindings are as follows: 272.Bl -tag -width indent 273.It Ic space 274Update the display. 275.It Ic / 276Filter by command name. 277Prompt for 278.Ar string 279or 280.Ql Ic + 281to show all processes. 282.It Ic a 283Toggle display of process titles. 284.It Ic C 285Toggle display of raw or weighted CPU percentage. 286.It Ic d 287Change the number of remaining displays to show before exit. 288Prompt for new number. 289.It Ic e 290Display a list of system errors (if any) generated by the last command. 291.It Ic H 292Toggle display of threads. 293.It Ic h No or Ic \&? 294Display a summary of the commands (help screen) and version information. 295.It Ic i No or Ic I 296Toggle display of idle processes. 297.It Ic J 298Filter processes owned by a specific jail. 299Prompt for jail name or 300.Ql Ic + 301for all processes belonging to all jails and the host. 302This will also enable the display of JID. 303.It Ic j 304Toggle display of 305.Xr jail 8 306ID. 307.It Ic k 308Send a signal 309.Pq SIGKILL by default 310to a list of processes. 311This acts similarly to the command 312.Xr kill 1 . 313.It Ic m 314Toggle the display between 'cpu' and 'io' modes. 315.It Ic n No or Ic # 316Change the number of processes to display. 317Prompt for new number. 318.It Ic o 319Change the order in which the display is sorted. 320The sort key names include 321.Dq cpu , 322.Dq res , 323.Dq size , 324and 325.Dq time. 326The default is cpu. 327.It Ic P 328Toggle display of per-CPU statistics. 329.It Ic p 330Filter by exact process ID. 331Prompt for 332.Ar PID 333or 334.Ql Ic + 335to show all processes. 336.It Ic q 337Quit 338.Nm . 339.It Ic r 340Change the priority 341.Pq the Dq nice 342of a list of processes. 343This acts similarly to 344.Xr renice 8 . 345.It Ic S 346Toggle the display of system processes. 347.It Ic s 348Change the number of seconds to delay between displays. 349Prompt for new number. 350.It Ic T 351Toggle display between thread ID and process ID. 352.It Ic t 353Toggle display of the 354.Nm 355process. 356.It Ic u 357Filter by exact process owner username. 358Prompt for 359.Ar username 360or 361.Ql Ic - Ns 362.No / Ns 363.Ql Ic + 364for all users. 365Usernames can be added 366to and removed from the set by prepending them with 367.Ql + 368and 369.Ql - , 370respectively. 371.It Ic w 372Toggle display of swap usage. 373.It Ic z 374Toggle display of the system idle process. 375.El 376.Sh "THE DISPLAY" 377The top few lines of the display show general information 378about the state of the system, including 379the last process id assigned to a process (on most systems), 380the three load averages, 381the current time, 382the number of existing processes, 383the number of processes in each state 384(sleeping, running, starting, zombies, and stopped), 385and a percentage of time spent in each of the processor states 386(user, nice, system, and idle). 387It also includes information about physical and virtual memory allocation. 388.Pp 389The remainder of the screen displays information about individual 390processes. 391This display is similar in spirit to 392.Xr ps 1 393but it is not exactly the same. 394PID is the process id, 395JID, when displayed, is the 396.Xr jail 8 397ID corresponding to the process, 398USERNAME is the name of the process's owner (if 399.Fl u 400is specified, a UID column will be substituted for USERNAME), 401PRI is the current priority of the process, 402NICE is the 403.Xr nice 1 404amount, 405SIZE is the total size of the process (text, data, and stack), 406RES is the current amount of resident memory, 407SWAP is the approximate amount of swap, if enabled 408(SIZE, RES and SWAP are given in kilobytes), 409STATE is the current state (one of 410.Dq START , 411.Dq RUN 412(shown as 413.Dq CPUn 414on SMP systems), 415.Dq SLEEP , 416.Dq STOP , 417.Dq ZOMB , 418.Dq WAIT , 419.Dq LOCK , 420or the event on which the process waits), 421C is the processor number on which the process is executing 422(visible only on SMP systems), 423TIME is the number of system and user cpu seconds that the process has used, 424WCPU, when displayed, is the weighted cpu percentage (this is the same 425value that 426.Xr ps 1 427displays as CPU), 428CPU is the raw percentage and is the field that is sorted to determine 429the order of the processes, and 430COMMAND is the name of the command that the process is currently running 431(if the process is swapped out, this column is marked 432.Dq <swapped> ) . 433.Pp 434If a process is in the 435.Dq SLEEP 436or 437.Dq LOCK 438state, 439the state column will report the name of the event or lock on which the 440process is waiting. 441Lock names are prefixed with an asterisk 442.Dq * 443while sleep events 444are not. 445.Sh DESCRIPTION OF MEMORY 446.Bd -literal 447Mem: 61M Active, 86M Inact, 368K Laundry, 22G Wired, 102G Free 448ARC: 15G Total, 9303M MFU, 6155M MRU, 1464K Anon, 98M Header, 35M Other 449 15G Compressed, 27G Uncompressed, 1.75:1 Ratio, 174M Overhead 450Swap: 4096M Total, 532M Free, 13% Inuse, 80K In, 104K Out 451.Ed 452.Ss Physical Memory Stats 453.Bl -tag -width "Uncompressed" -compact 454.It Em Active 455number of bytes active 456.It Em Inact 457number of clean bytes inactive 458.It Em Laundry 459number of dirty bytes queued for laundering 460.It Em Wired 461number of bytes wired down, including IO-level cached file data pages 462.It Em Buf 463number of bytes used for IO-level disk caching 464.It Em Free 465number of bytes free 466.El 467.Ss ZFS ARC Stats 468These stats are only displayed when the ARC is in use. 469.Pp 470.Bl -tag -width "Uncompressed" -compact 471.It Em Total 472number of wired bytes used for the ZFS ARC 473.It Em MRU 474number of ARC bytes holding most recently used data 475.It Em MFU 476number of ARC bytes holding most frequently used data 477.It Em Anon 478number of ARC bytes holding in flight data 479.It Em Header 480number of ARC bytes holding headers 481.It Em Other 482miscellaneous ARC bytes 483.It Em Compressed 484bytes of memory used by ARC caches 485.It Em Uncompressed 486bytes of data stored in ARC caches before compression 487.It Em Ratio 488compression ratio of data cached in the ARC 489.El 490.Ss Swap Stats 491.Bl -tag -width "Uncompressed" -compact 492.It Em Total 493total available swap usage 494.It Em Free 495total free swap usage 496.It Em Inuse 497swap usage 498.It Em \&In 499bytes paged in from swap devices (last interval) 500.It Em Out 501bytes paged out to swap devices (last interval) 502.El 503.Sh ENVIRONMENT 504.Bl -tag -width "Uncompressed" 505.It Ev TOP 506Default set of arguments to 507.Nm . 508.It Ev LC_CTYPE 509The locale to use when displaying the 510.Va argv 511vector when 512.Fl a 513flag is specified. 514.El 515.Sh SEE ALSO 516.Xr kill 1 , 517.Xr ps 1 , 518.Xr stty 1 , 519.Xr getrusage 2 , 520.Xr humanize_number 3 , 521.Xr mem 4 , 522.Xr renice 8 523.Sh HISTORY 524.Nm 525first appeared in 526.Fx 2.2.2 . 527.Sh AUTHORS 528.An William LeFebvre, EECS Department, Northwestern University 529.Sh BUGS 530The command name for swapped processes should be tracked down, but this 531would make the program run slower. 532.Pp 533As with 534.Xr ps 1 , 535things can change while 536.Nm 537is collecting information for an update. 538The picture it gives is only a close approximation to reality. 539