1TOP(1) User Commands TOP(1)
2
3
4
6 top - display Linux processes
7
8
10 top -hv|-bcEeHiOSs1 -d secs -n max -u|U user -p pids -o field -w [cols]
11
12 The traditional switches `-' and whitespace are optional.
13
14
16 The top program provides a dynamic real-time view of a running system.
17 It can display system summary information as well as a list of
18 processes or threads currently being managed by the Linux kernel. The
19 types of system summary information shown and the types, order and size
20 of information displayed for processes are all user configurable and
21 that configuration can be made persistent across restarts.
22
23 The program provides a limited interactive interface for process
24 manipulation as well as a much more extensive interface for personal
25 configuration -- encompassing every aspect of its operation. And
26 while top is referred to throughout this document, you are free to name
27 the program anything you wish. That new name, possibly an alias, will
28 then be reflected on top's display and used when reading and writing a
29 configuration file.
30
31
33 Documentation
34 The remaining Table of Contents
35
36 OVERVIEW
37 Operation
38 Linux Memory Types
39 1. COMMAND-LINE Options
40 2. SUMMARY Display
41 a. UPTIME and LOAD Averages
42 b. TASK and CPU States
43 c. MEMORY Usage
44 3. FIELDS / Columns Display
45 a. DESCRIPTIONS of Fields
46 b. MANAGING Fields
47 4. INTERACTIVE Commands
48 a. GLOBAL Commands
49 b. SUMMARY AREA Commands
50 c. TASK AREA Commands
51 1. Appearance
52 2. Content
53 3. Size
54 4. Sorting
55 d. COLOR Mapping
56 5. ALTERNATE-DISPLAY Provisions
57 a. WINDOWS Overview
58 b. COMMANDS for Windows
59 c. SCROLLING a Window
60 d. SEARCHING in a Window
61 e. FILTERING in a Window
62 6. FILES
63 a. PERSONAL Configuration File
64 b. ADDING INSPECT Entries
65 c. SYSTEM Configuration File
66 d. SYSTEM Restrictions File
67 7. STUPID TRICKS Sampler
68 a. Kernel Magic
69 b. Bouncing Windows
70 c. The Big Bird Window
71 d. The Ol' Switcheroo
72 8. BUGS, 9. SEE Also
73
74
75 Operation
76 When operating top, the two most important keys are the help (h or ?)
77 key and quit (`q') key. Alternatively, you could simply use the
78 traditional interrupt key (^C) when you're done.
79
80 When started for the first time, you'll be presented with these
81 traditional elements on the main top screen: 1) Summary Area; 2)
82 Fields/Columns Header; 3) Task Area. Each of these will be explored in
83 the sections that follow. There is also an Input/Message line between
84 the Summary Area and Columns Header which needs no further explanation.
85
86 The main top screen is generally quite adaptive to changes in terminal
87 dimensions under X-Windows. Other top screens may be less so,
88 especially those with static text. It ultimately depends, however, on
89 your particular window manager and terminal emulator. There may be
90 occasions when their view of terminal size and current contents differs
91 from top's view, which is always based on operating system calls.
92
93 Following any re-size operation, if a top screen is corrupted, appears
94 incomplete or disordered, simply typing something innocuous like a
95 punctuation character or cursor motion key will usually restore it. In
96 extreme cases, the following sequence almost certainly will:
97 key/cmd objective
98 ^Z suspend top
99 fg resume top
100 <Left> force a screen redraw (if necessary)
101
102 But if the display is still corrupted, there is one more step you could
103 try. Insert this command after top has been suspended but before
104 resuming it.
105 key/cmd objective
106 reset restore your terminal settings
107
108 Note: the width of top's display will be limited to 512 positions.
109 Displaying all fields requires approximately 250 characters. Remaining
110 screen width is usually allocated to any variable width columns
111 currently visible. The variable width columns, such as COMMAND, are
112 noted in topic 3a. DESCRIPTIONS of Fields. Actual output width may
113 also be influenced by the -w switch, which is discussed in topic 1.
114 COMMAND-LINE Options.
115
116 Lastly, some of top's screens or functions require the use of cursor
117 motion keys like the standard arrow keys plus the Home, End, PgUp and
118 PgDn keys. If your terminal or emulator does not provide those keys,
119 the following combinations are accepted as alternatives:
120 key equivalent-keys
121 Left alt + h
122 Down alt + j
123 Up alt + k
124 Right alt + l
125 Home alt + ctrl + h
126 PgDn alt + ctrl + j
127 PgUp alt + ctrl + k
128 End alt + ctrl + l
129
130 The Up and Down arrow keys have special significance when prompted for
131 line input terminated with the <Enter> key. Those keys, or their
132 aliases, can be used to retrieve previous input lines which can then be
133 edited and re-input. And there are four additional keys available with
134 line oriented input.
135 key special-significance
136 Up recall older strings for re-editing
137 Down recall newer strings or erase entire line
138 Insert toggle between insert and overtype modes
139 Delete character removed at cursor, moving others left
140 Home jump to beginning of input line
141 End jump to end of input line
142
143
144 Linux Memory Types
145 For our purposes there are three types of memory, and one is optional.
146 First is physical memory, a limited resource where code and data must
147 reside when executed or referenced. Next is the optional swap file,
148 where modified (dirty) memory can be saved and later retrieved if too
149 many demands are made on physical memory. Lastly we have virtual
150 memory, a nearly unlimited resource serving the following goals:
151
152 1. abstraction, free from physical memory addresses/limits
153 2. isolation, every process in a separate address space
154 3. sharing, a single mapping can serve multiple needs
155 4. flexibility, assign a virtual address to a file
156
157 Regardless of which of these forms memory may take, all are managed as
158 pages (typically 4096 bytes) but expressed by default in top as KiB
159 (kibibyte). The memory discussed under topic `2c. MEMORY Usage' deals
160 with physical memory and the swap file for the system as a whole. The
161 memory reviewed in topic `3. FIELDS / Columns Display' embraces all
162 three memory types, but for individual processes.
163
164 For each such process, every memory page is restricted to a single
165 quadrant from the table below. Both physical memory and virtual memory
166 can include any of the four, while the swap file only includes #1
167 through #3. The memory in quadrant #4, when modified, acts as its own
168 dedicated swap file.
169
170 Private | Shared
171 1 | 2
172 Anonymous . stack |
173 . malloc() |
174 . brk()/sbrk() | . POSIX shm*
175 . mmap(PRIVATE, ANON) | . mmap(SHARED, ANON)
176 -----------------------+----------------------
177 . mmap(PRIVATE, fd) | . mmap(SHARED, fd)
178 File-backed . pgms/shared libs |
179 3 | 4
180
181 The following may help in interpreting process level memory values
182 displayed as scalable columns and discussed under topic `3a.
183 DESCRIPTIONS of Fields'.
184
185 %MEM - simply RES divided by total physical memory
186 CODE - the `pgms' portion of quadrant 3
187 DATA - the entire quadrant 1 portion of VIRT plus all
188 explicit mmap file-backed pages of quadrant 3
189 RES - anything occupying physical memory which, beginning with
190 Linux-4.5, is the sum of the following three fields:
191 RSan - quadrant 1 pages, which include any
192 former quadrant 3 pages if modified
193 RSfd - quadrant 3 and quadrant 4 pages
194 RSsh - quadrant 2 pages
195 RSlk - subset of RES which cannot be swapped out (any quadrant)
196 SHR - subset of RES (excludes 1, includes all 2 & 4, some 3)
197 SWAP - potentially any quadrant except 4
198 USED - simply the sum of RES and SWAP
199 VIRT - everything in-use and/or reserved (all quadrants)
200
201 Note: Even though program images and shared libraries are considered
202 private to a process, they will be accounted for as shared (SHR) by the
203 kernel.
204
205
207 The command-line syntax for top consists of:
208
209 -hv|-bcEeHiOSs1 -d secs -n max -u|U user -p pids -o field -w [cols]
210
211 The typically mandatory switch (`-') and even whitespace are completely
212 optional.
213
214
215 -h | -v :Help/Version
216 Show library version and the usage prompt, then quit.
217
218
219 -b :Batch-mode operation
220 Starts top in Batch mode, which could be useful for sending output
221 from top to other programs or to a file. In this mode, top will
222 not accept input and runs until the iterations limit you've set
223 with the `-n' command-line option or until killed.
224
225
226 -c :Command-line/Program-name toggle
227 Starts top with the last remembered `c' state reversed. Thus, if
228 top was displaying command lines, now that field will show program
229 names, and vice versa. See the `c' interactive command for
230 additional information.
231
232
233 -d :Delay-time interval as: -d ss.t (secs.tenths)
234 Specifies the delay between screen updates, and overrides the
235 corresponding value in one's personal configuration file or the
236 startup default. Later this can be changed with the `d' or `s'
237 interactive commands.
238
239 Fractional seconds are honored, but a negative number is not
240 allowed. In all cases, however, such changes are prohibited if
241 top is running in Secure mode, except for root (unless the `s'
242 command-line option was used). For additional information on
243 Secure mode see topic 6d. SYSTEM Restrictions File.
244
245
246 -e :Enforce-Task-Memory-Scaling as: -e k | m | g | t | p
247 Instructs top to force task area memory to be scaled as:
248 k - kibibytes
249 m - mebibytes
250 g - gibibytes
251 t - tebibytes
252 p - pebibytes
253
254 Later this can be changed with the `e' command toggle.
255
256
257 -E :Enforce-Summary-Memory-Scaling as: -E k | m | g | t | p | e
258 Instructs top to force summary area memory to be scaled as:
259 k - kibibytes
260 m - mebibytes
261 g - gibibytes
262 t - tebibytes
263 p - pebibytes
264 e - exbibytes
265
266 Later this can be changed with the `E' command toggle.
267
268
269 -H :Threads-mode operation
270 Instructs top to display individual threads. Without this
271 command-line option a summation of all threads in each process is
272 shown. Later this can be changed with the `H' interactive
273 command.
274
275
276 -i :Idle-process toggle
277 Starts top with the last remembered `i' state reversed. When this
278 toggle is Off, tasks that have not used any CPU since the last
279 update will not be displayed. For additional information
280 regarding this toggle see topic 4c. TASK AREA Commands, SIZE.
281
282
283 -n :Number-of-iterations limit as: -n number
284 Specifies the maximum number of iterations, or frames, top should
285 produce before ending.
286
287
288 -o :Override-sort-field as: -o fieldname
289 Specifies the name of the field on which tasks will be sorted,
290 independent of what is reflected in the configuration file. You
291 can prepend a `+' or `-' to the field name to also override the
292 sort direction. A leading `+' will force sorting high to low,
293 whereas a `-' will ensure a low to high ordering.
294
295 This option exists primarily to support automated/scripted batch
296 mode operation.
297
298
299 -O :Output-field-names
300 This option acts as a form of help for the above -o option. It
301 will cause top to print each of the available field names on a
302 separate line, then quit. Such names are subject to NLS (National
303 Language Support) translation.
304
305
306 -p :Monitor-PIDs mode as: -pN1 -pN2 ... or -pN1,N2,N3 ...
307 Monitor only processes with specified process IDs. This option
308 can be given up to 20 times, or you can provide a comma delimited
309 list with up to 20 pids. Co-mingling both approaches is
310 permitted.
311
312 A pid value of zero will be treated as the process id of the top
313 program itself once it is running.
314
315 This is a command-line option only and should you wish to return
316 to normal operation, it is not necessary to quit and restart top
317 -- just issue any of these interactive commands: `=', `u' or
318 `U'.
319
320 The `p', `u' and `U' command-line options are mutually exclusive.
321
322
323 -s :Secure-mode operation
324 Starts top with secure mode forced, even for root. This mode is
325 far better controlled through a system configuration file (see
326 topic 6. FILES).
327
328
329 -S :Cumulative-time toggle
330 Starts top with the last remembered `S' state reversed. When
331 Cumulative time mode is On, each process is listed with the cpu
332 time that it and its dead children have used. See the `S'
333 interactive command for additional information regarding this
334 mode.
335
336
337 -u | -U :User-filter-mode as: -u | -U number or name
338 Display only processes with a user id or user name matching that
339 given. The `-u' option matches on effective user whereas the
340 `-U' option matches on any user (real, effective, saved, or
341 filesystem).
342
343 Prepending an exclamation point (`!') to the user id or name
344 instructs top to display only processes with users not matching
345 the one provided.
346
347 The `p', `u' and `U' command-line options are mutually exclusive.
348
349
350 -w :Output-width-override as: -w [ number ]
351 In Batch mode, when used without an argument top will format
352 output using the COLUMNS= and LINES= environment variables, if
353 set. Otherwise, width will be fixed at the maximum 512 columns.
354 With an argument, output width can be decreased or increased (up
355 to 512) but the number of rows is considered unlimited.
356
357 In normal display mode, when used without an argument top will
358 attempt to format output using the COLUMNS= and LINES= environment
359 variables, if set. With an argument, output width can only be
360 decreased, not increased. Whether using environment variables or
361 an argument with -w, when not in Batch mode actual terminal
362 dimensions can never be exceeded.
363
364 Note: Without the use of this command-line option, output width is
365 always based on the terminal at which top was invoked whether or
366 not in Batch mode.
367
368
369 -1 :Single/Separate-Cpu-States toggle
370 Starts top with the last remembered Cpu States portion of the
371 summary area reversed. Either all cpu information will be
372 displayed in a single line or each cpu will be displayed
373 separately, depending on the state of the NUMA Node command toggle
374 ('2').
375
376 See the `1' and '2' interactive commands for additional
377 information.
378
379
381 Each of the following three areas are individually controlled through
382 one or more interactive commands. See topic 4b. SUMMARY AREA Commands
383 for additional information regarding these provisions.
384
385
386 2a. UPTIME and LOAD Averages
387 This portion consists of a single line containing:
388 program or window name, depending on display mode
389 current time and length of time since last boot
390 total number of users
391 system load avg over the last 1, 5 and 15 minutes
392
393
394 2b. TASK and CPU States
395 This portion consists of a minimum of two lines. In an SMP
396 environment, additional lines can reflect individual CPU state
397 percentages.
398
399 Line 1 shows total tasks or threads, depending on the state of the
400 Threads-mode toggle. That total is further classified as:
401 running; sleeping; stopped; zombie
402
403 Line 2 shows CPU state percentages based on the interval since the last
404 refresh.
405
406 As a default, percentages for these individual categories are
407 displayed. Where two labels are shown below, those for more recent
408 kernel versions are shown first.
409 us, user : time running un-niced user processes
410 sy, system : time running kernel processes
411 ni, nice : time running niced user processes
412 id, idle : time spent in the kernel idle handler
413 wa, IO-wait : time waiting for I/O completion
414 hi : time spent servicing hardware interrupts
415 si : time spent servicing software interrupts
416 st : time stolen from this vm by the hypervisor
417
418 In the alternate cpu states display modes, beyond the first
419 tasks/threads line, an abbreviated summary is shown consisting of these
420 elements:
421 a b c d
422 %Cpu(s): 75.0/25.0 100[ ...
423
424
425 Where: a) is the `user' (us + ni) percentage; b) is the `system' (sy +
426 hi + si) percentage; c) is the total; and d) is one of two visual
427 graphs of those representations. See topic 4b. SUMMARY AREA Commands
428 and the `t' command for additional information on that special 4-way
429 toggle.
430
431
432 2c. MEMORY Usage
433 This portion consists of two lines which may express values in
434 kibibytes (KiB) through exbibytes (EiB) depending on the scaling factor
435 enforced with the `E' interactive command.
436
437 As a default, Line 1 reflects physical memory, classified as:
438 total, free, used and buff/cache
439
440 Line 2 reflects mostly virtual memory, classified as:
441 total, free, used and avail (which is physical memory)
442
443 The avail number on line 2 is an estimation of physical memory
444 available for starting new applications, without swapping. Unlike the
445 free field, it attempts to account for readily reclaimable page cache
446 and memory slabs. It is available on kernels 3.14, emulated on kernels
447 2.6.27+, otherwise the same as free.
448
449 In the alternate memory display modes, two abbreviated summary lines
450 are shown consisting of these elements:
451 a b c
452 GiB Mem : 18.7/15.738 [ ...
453 GiB Swap: 0.0/7.999 [ ...
454
455 Where: a) is the percentage used; b) is the total available; and c) is
456 one of two visual graphs of those representations.
457
458 In the case of physical memory, the percentage represents the total
459 minus the estimated avail noted above. The `Mem' graph itself is
460 divided between used and any remaining memory not otherwise accounted
461 for by avail. See topic 4b. SUMMARY AREA Commands and the `m' command
462 for additional information on that special 4-way toggle.
463
464 This table may help in interpreting the scaled values displayed:
465 KiB = kibibyte = 1024 bytes
466 MiB = mebibyte = 1024 KiB = 1,048,576 bytes
467 GiB = gibibyte = 1024 MiB = 1,073,741,824 bytes
468 TiB = tebibyte = 1024 GiB = 1,099,511,627,776 bytes
469 PiB = pebibyte = 1024 TiB = 1,125,899,906,842,624 bytes
470 EiB = exbibyte = 1024 PiB = 1,152,921,504,606,846,976 bytes
471
472
474 3a. DESCRIPTIONS of Fields
475 Listed below are top's available process fields (columns). They are
476 shown in strict ascii alphabetical order. You may customize their
477 position and whether or not they are displayable with the `f' or `F'
478 (Fields Management) interactive commands.
479
480 Any field is selectable as the sort field, and you control whether they
481 are sorted high-to-low or low-to-high. For additional information on
482 sort provisions see topic 4c. TASK AREA Commands, SORTING.
483
484 The fields related to physical memory or virtual memory reference
485 `(KiB)' which is the unsuffixed display mode. Such fields may,
486 however, be scaled from KiB through PiB. That scaling is influenced
487 via the `e' interactive command or established for startup through a
488 build option.
489
490
491 1. %CPU -- CPU Usage
492 The task's share of the elapsed CPU time since the last screen
493 update, expressed as a percentage of total CPU time.
494
495 In a true SMP environment, if a process is multi-threaded and top
496 is not operating in Threads mode, amounts greater than 100% may be
497 reported. You toggle Threads mode with the `H' interactive
498 command.
499
500 Also for multi-processor environments, if Irix mode is Off, top
501 will operate in Solaris mode where a task's cpu usage will be
502 divided by the total number of CPUs. You toggle Irix/Solaris modes
503 with the `I' interactive command.
504
505 Note: When running in forest view mode (`V') with children
506 collapsed (`v'), this field will also include the CPU time of those
507 unseen children. See topic 4c. TASK AREA Commands, CONTENT for
508 more information regarding the `V' and `v' toggles.
509
510
511 2. %MEM -- Memory Usage (RES)
512 A task's currently resident share of available physical memory.
513
514 See `OVERVIEW, Linux Memory Types' for additional details.
515
516
517 3. CGNAME -- Control Group Name
518 The name of the control group to which a process belongs, or `-' if
519 not applicable for that process.
520
521 This will typically be the last entry in the full list of control
522 groups as shown under the next heading (CGROUPS). And as is true
523 there, this field is also variable width.
524
525
526 4. CGROUPS -- Control Groups
527 The names of the control group(s) to which a process belongs, or
528 `-' if not applicable for that process.
529
530 Control Groups provide for allocating resources (cpu, memory,
531 network bandwidth, etc.) among installation-defined groups of
532 processes. They enable fine-grained control over allocating,
533 denying, prioritizing, managing and monitoring those resources.
534
535 Many different hierarchies of cgroups can exist simultaneously on a
536 system and each hierarchy is attached to one or more subsystems. A
537 subsystem represents a single resource.
538
539 Note: The CGROUPS field, unlike most columns, is not fixed-width.
540 When displayed, it plus any other variable width columns will be
541 allocated all remaining screen width (up to the maximum 512
542 characters). Even so, such variable width fields could still
543 suffer truncation. See topic 5c. SCROLLING a Window for additional
544 information on accessing any truncated data.
545
546
547 5. CODE -- Code Size (KiB)
548 The amount of physical memory currently devoted to executable code,
549 also known as the Text Resident Set size or TRS.
550
551 See `OVERVIEW, Linux Memory Types' for additional details.
552
553
554 6. COMMAND -- Command Name or Command Line
555 Display the command line used to start a task or the name of the
556 associated program. You toggle between command line and name with
557 `c', which is both a command-line option and an interactive
558 command.
559
560 When you've chosen to display command lines, processes without a
561 command line (like kernel threads) will be shown with only the
562 program name in brackets, as in this example:
563 [kthreadd]
564
565 This field may also be impacted by the forest view display mode.
566 See the `V' interactive command for additional information
567 regarding that mode.
568
569 Note: The COMMAND field, unlike most columns, is not fixed-width.
570 When displayed, it plus any other variable width columns will be
571 allocated all remaining screen width (up to the maximum 512
572 characters). Even so, such variable width fields could still
573 suffer truncation. This is especially true for this field when
574 command lines are being displayed (the `c' interactive command.)
575 See topic 5c. SCROLLING a Window for additional information on
576 accessing any truncated data.
577
578
579 7. DATA -- Data + Stack Size (KiB)
580 The amount of private memory reserved by a process. It is also
581 known as the Data Resident Set or DRS. Such memory may not yet be
582 mapped to physical memory (RES) but will always be included in the
583 virtual memory (VIRT) amount.
584
585 See `OVERVIEW, Linux Memory Types' for additional details.
586
587
588 8. ENVIRON -- Environment variables
589 Display all of the environment variables, if any, as seen by the
590 respective processes. These variables will be displayed in their
591 raw native order, not the sorted order you are accustomed to seeing
592 with an unqualified `set'.
593
594 Note: The ENVIRON field, unlike most columns, is not fixed-width.
595 When displayed, it plus any other variable width columns will be
596 allocated all remaining screen width (up to the maximum 512
597 characters). Even so, such variable width fields could still
598 suffer truncation. This is especially true for this field. See
599 topic 5c. SCROLLING a Window for additional information on
600 accessing any truncated data.
601
602
603 9. Flags -- Task Flags
604 This column represents the task's current scheduling flags which
605 are expressed in hexadecimal notation and with zeros suppressed.
606 These flags are officially documented in <linux/sched.h>.
607
608
609 10. GID -- Group Id
610 The effective group ID.
611
612
613 11. GROUP -- Group Name
614 The effective group name.
615
616
617 12. LXC -- Lxc Container Name
618 The name of the lxc container within which a task is running. If a
619 process is not running inside a container, a dash (`-') will be
620 shown.
621
622
623 13. NI -- Nice Value
624 The nice value of the task. A negative nice value means higher
625 priority, whereas a positive nice value means lower priority. Zero
626 in this field simply means priority will not be adjusted in
627 determining a task's dispatch-ability.
628
629
630 14. NU -- Last known NUMA node
631 A number representing the NUMA node associated with the last used
632 processor (`P'). When -1 is displayed it means that NUMA
633 information is not available.
634
635 See the `'2' and `3' interactive commands for additional NUMA
636 provisions affecting the summary area.
637
638
639 15. OOMa -- Out of Memory Adjustment Factor
640 The value, ranging from -1000 to +1000, added to the current out of
641 memory score (OOMs) which is then used to determine which task to
642 kill when memory is exhausted.
643
644
645 16. OOMs -- Out of Memory Score
646 The value, ranging from 0 to +1000, used to select task(s) to kill
647 when memory is exhausted. Zero translates to `never kill' whereas
648 1000 means `always kill'.
649
650
651 17. P -- Last used CPU (SMP)
652 A number representing the last used processor. In a true SMP
653 environment this will likely change frequently since the kernel
654 intentionally uses weak affinity. Also, the very act of running
655 top may break this weak affinity and cause more processes to change
656 CPUs more often (because of the extra demand for cpu time).
657
658
659 18. PGRP -- Process Group Id
660 Every process is member of a unique process group which is used for
661 distribution of signals and by terminals to arbitrate requests for
662 their input and output. When a process is created (forked), it
663 becomes a member of the process group of its parent. By
664 convention, this value equals the process ID (see PID) of the first
665 member of a process group, called the process group leader.
666
667
668 19. PID -- Process Id
669 The task's unique process ID, which periodically wraps, though
670 never restarting at zero. In kernel terms, it is a dispatchable
671 entity defined by a task_struct.
672
673 This value may also be used as: a process group ID (see PGRP); a
674 session ID for the session leader (see SID); a thread group ID for
675 the thread group leader (see TGID); and a TTY process group ID for
676 the process group leader (see TPGID).
677
678
679 20. PPID -- Parent Process Id
680 The process ID (pid) of a task's parent.
681
682
683 21. PR -- Priority
684 The scheduling priority of the task. If you see `rt' in this
685 field, it means the task is running under real time scheduling
686 priority.
687
688 Under linux, real time priority is somewhat misleading since
689 traditionally the operating itself was not preemptible. And while
690 the 2.6 kernel can be made mostly preemptible, it is not always so.
691
692
693 22. RES -- Resident Memory Size (KiB)
694 A subset of the virtual address space (VIRT) representing the non-
695 swapped physical memory a task is currently using. It is also the
696 sum of the RSan, RSfd and RSsh fields.
697
698 It can include private anonymous pages, private pages mapped to
699 files (including program images and shared libraries) plus shared
700 anonymous pages. All such memory is backed by the swap file
701 represented separately under SWAP.
702
703 Lastly, this field may also include shared file-backed pages which,
704 when modified, act as a dedicated swap file and thus will never
705 impact SWAP.
706
707 See `OVERVIEW, Linux Memory Types' for additional details.
708
709
710 23. RSan -- Resident Anonymous Memory Size (KiB)
711 A subset of resident memory (RES) representing private pages not
712 mapped to a file.
713
714
715 24. RSfd -- Resident File-Backed Memory Size (KiB)
716 A subset of resident memory (RES) representing the implicitly
717 shared pages supporting program images and shared libraries. It
718 also includes explicit file mappings, both private and shared.
719
720
721 25. RSlk -- Resident Locked Memory Size (KiB)
722 A subset of resident memory (RES) which cannot be swapped out.
723
724
725 26. RSsh -- Resident Shared Memory Size (KiB)
726 A subset of resident memory (RES) representing the explicitly
727 shared anonymous shm*/mmap pages.
728
729
730 27. RUID -- Real User Id
731 The real user ID.
732
733
734 28. RUSER -- Real User Name
735 The real user name.
736
737
738 29. S -- Process Status
739 The status of the task which can be one of:
740 D = uninterruptible sleep
741 I = idle
742 R = running
743 S = sleeping
744 T = stopped by job control signal
745 t = stopped by debugger during trace
746 Z = zombie
747
748 Tasks shown as running should be more properly thought of as ready
749 to run -- their task_struct is simply represented on the Linux
750 run-queue. Even without a true SMP machine, you may see numerous
751 tasks in this state depending on top's delay interval and nice
752 value.
753
754
755 30. SHR -- Shared Memory Size (KiB)
756 A subset of resident memory (RES) that may be used by other
757 processes. It will include shared anonymous pages and shared file-
758 backed pages. It also includes private pages mapped to files
759 representing program images and shared libraries.
760
761 See `OVERVIEW, Linux Memory Types' for additional details.
762
763
764 31. SID -- Session Id
765 A session is a collection of process groups (see PGRP), usually
766 established by the login shell. A newly forked process joins the
767 session of its creator. By convention, this value equals the
768 process ID (see PID) of the first member of the session, called the
769 session leader, which is usually the login shell.
770
771
772 32. SUID -- Saved User Id
773 The saved user ID.
774
775
776 33. SUPGIDS -- Supplementary Group IDs
777 The IDs of any supplementary group(s) established at login or
778 inherited from a task's parent. They are displayed in a comma
779 delimited list.
780
781 Note: The SUPGIDS field, unlike most columns, is not fixed-width.
782 When displayed, it plus any other variable width columns will be
783 allocated all remaining screen width (up to the maximum 512
784 characters). Even so, such variable width fields could still
785 suffer truncation. See topic 5c. SCROLLING a Window for additional
786 information on accessing any truncated data.
787
788
789 34. SUPGRPS -- Supplementary Group Names
790 The names of any supplementary group(s) established at login or
791 inherited from a task's parent. They are displayed in a comma
792 delimited list.
793
794 Note: The SUPGRPS field, unlike most columns, is not fixed-width.
795 When displayed, it plus any other variable width columns will be
796 allocated all remaining screen width (up to the maximum 512
797 characters). Even so, such variable width fields could still
798 suffer truncation. See topic 5c. SCROLLING a Window for additional
799 information on accessing any truncated data.
800
801
802 35. SUSER -- Saved User Name
803 The saved user name.
804
805
806 36. SWAP -- Swapped Size (KiB)
807 The formerly resident portion of a task's address space written to
808 the swap file when physical memory becomes over committed.
809
810 See `OVERVIEW, Linux Memory Types' for additional details.
811
812
813 37. TGID -- Thread Group Id
814 The ID of the thread group to which a task belongs. It is the PID
815 of the thread group leader. In kernel terms, it represents those
816 tasks that share an mm_struct.
817
818
819 38. TIME -- CPU Time
820 Total CPU time the task has used since it started. When Cumulative
821 mode is On, each process is listed with the cpu time that it and
822 its dead children have used. You toggle Cumulative mode with `S',
823 which is both a command-line option and an interactive command.
824 See the `S' interactive command for additional information
825 regarding this mode.
826
827
828 39. TIME+ -- CPU Time, hundredths
829 The same as TIME, but reflecting more granularity through
830 hundredths of a second.
831
832
833 40. TPGID -- Tty Process Group Id
834 The process group ID of the foreground process for the connected
835 tty, or -1 if a process is not connected to a terminal. By
836 convention, this value equals the process ID (see PID) of the
837 process group leader (see PGRP).
838
839
840 41. TTY -- Controlling Tty
841 The name of the controlling terminal. This is usually the device
842 (serial port, pty, etc.) from which the process was started, and
843 which it uses for input or output. However, a task need not be
844 associated with a terminal, in which case you'll see `?' displayed.
845
846
847 42. UID -- User Id
848 The effective user ID of the task's owner.
849
850
851 43. USED -- Memory in Use (KiB)
852 This field represents the non-swapped physical memory a task is
853 using (RES) plus the swapped out portion of its address space
854 (SWAP).
855
856 See `OVERVIEW, Linux Memory Types' for additional details.
857
858
859 44. USER -- User Name
860 The effective user name of the task's owner.
861
862
863 45. VIRT -- Virtual Memory Size (KiB)
864 The total amount of virtual memory used by the task. It includes
865 all code, data and shared libraries plus pages that have been
866 swapped out and pages that have been mapped but not used.
867
868 See `OVERVIEW, Linux Memory Types' for additional details.
869
870
871 46. WCHAN -- Sleeping in Function
872 This field will show the name of the kernel function in which the
873 task is currently sleeping. Running tasks will display a dash
874 (`-') in this column.
875
876
877 47. nDRT -- Dirty Pages Count
878 The number of pages that have been modified since they were last
879 written to auxiliary storage. Dirty pages must be written to
880 auxiliary storage before the corresponding physical memory location
881 can be used for some other virtual page.
882
883 This field was deprecated with linux 2.6 and is always zero.
884
885
886 48. nMaj -- Major Page Fault Count
887 The number of major page faults that have occurred for a task. A
888 page fault occurs when a process attempts to read from or write to
889 a virtual page that is not currently present in its address space.
890 A major page fault is when auxiliary storage access is involved in
891 making that page available.
892
893
894 49. nMin -- Minor Page Fault count
895 The number of minor page faults that have occurred for a task. A
896 page fault occurs when a process attempts to read from or write to
897 a virtual page that is not currently present in its address space.
898 A minor page fault does not involve auxiliary storage access in
899 making that page available.
900
901
902 50. nTH -- Number of Threads
903 The number of threads associated with a process.
904
905
906 51. nsIPC -- IPC namespace
907 The Inode of the namespace used to isolate interprocess
908 communication (IPC) resources such as System V IPC objects and
909 POSIX message queues.
910
911
912 52. nsMNT -- MNT namespace
913 The Inode of the namespace used to isolate filesystem mount points
914 thus offering different views of the filesystem hierarchy.
915
916
917 53. nsNET -- NET namespace
918 The Inode of the namespace used to isolate resources such as
919 network devices, IP addresses, IP routing, port numbers, etc.
920
921
922 54. nsPID -- PID namespace
923 The Inode of the namespace used to isolate process ID numbers
924 meaning they need not remain unique. Thus, each such namespace
925 could have its own `init/systemd' (PID #1) to manage various
926 initialization tasks and reap orphaned child processes.
927
928
929 55. nsUSER -- USER namespace
930 The Inode of the namespace used to isolate the user and group ID
931 numbers. Thus, a process could have a normal unprivileged user ID
932 outside a user namespace while having a user ID of 0, with full
933 root privileges, inside that namespace.
934
935
936 56. nsUTS -- UTS namespace
937 The Inode of the namespace used to isolate hostname and NIS domain
938 name. UTS simply means "UNIX Time-sharing System".
939
940
941 57. vMj -- Major Page Fault Count Delta
942 The number of major page faults that have occurred since the last
943 update (see nMaj).
944
945
946 58. vMn -- Minor Page Fault Count Delta
947 The number of minor page faults that have occurred since the last
948 update (see nMin).
949
950
951 3b. MANAGING Fields
952 After pressing the interactive command `f' or `F' (Fields Management)
953 you will be presented with a screen showing: 1) the `current' window
954 name; 2) the designated sort field; 3) all fields in their current
955 order along with descriptions. Entries marked with an asterisk are the
956 currently displayed fields, screen width permitting.
957
958
959 • As the on screen instructions indicate, you navigate among the
960 fields with the Up and Down arrow keys. The PgUp, PgDn, Home
961 and End keys can also be used to quickly reach the first or last
962 available field.
963
964
965 • The Right arrow key selects a field for repositioning and the
966 Left arrow key or the <Enter> key commits that field's
967 placement.
968
969
970 • The `d' key or the <Space> bar toggles a field's display status,
971 and thus the presence or absence of the asterisk.
972
973
974 • The `s' key designates a field as the sort field. See topic 4c.
975 TASK AREA Commands, SORTING for additional information regarding
976 your selection of a sort field.
977
978
979 • The `a' and `w' keys can be used to cycle through all available
980 windows and the `q' or <Esc> keys exit Fields Management.
981
982
983 The Fields Management screen can also be used to change the `current'
984 window/field group in either full-screen mode or alternate-display
985 mode. Whatever was targeted when `q' or <Esc> was pressed will be made
986 current as you return to the top display. See topic 5.
987 ALTERNATE-DISPLAY Provisions and the `g' interactive command for
988 insight into `current' windows and field groups.
989
990
991 Note: Any window that has been scrolled horizontally will be reset if
992 any field changes are made via the Fields Management screen. Any
993 vertical scrolled position, however, will not be affected. See topic
994 5c. SCROLLING a Window for additional information regarding vertical
995 and horizontal scrolling.
996
997
999 Listed below is a brief index of commands within categories. Some
1000 commands appear more than once -- their meaning or scope may vary
1001 depending on the context in which they are issued.
1002
1003 4a. Global-Commands
1004 <Ent/Sp> ?, =, 0,
1005 A, B, d, E, e, g, h, H, I, k, q, r, s, W, X, Y, Z
1006 4b. Summary-Area-Commands
1007 C, l, t, m, 1, 2, 3, 4, !
1008 4c. Task-Area-Commands
1009 Appearance: b, J, j, x, y, z
1010 Content: c, f, F, o, O, S, u, U, V, v
1011 Size: #, i, n
1012 Sorting: <, >, f, F, R
1013 4d. Color-Mapping
1014 <Ret>, a, B, b, H, M, q, S, T, w, z, 0 - 7
1015 5b. Commands-for-Windows
1016 -, _, =, +, A, a, g, G, w
1017 5c. Scrolling-a-Window
1018 C, Up, Dn, Left, Right, PgUp, PgDn, Home, End
1019 5d. Searching-in-a-Window
1020 L, &
1021
1022
1023 4a. GLOBAL Commands
1024 The global interactive commands are always available in both
1025 full-screen mode and alternate-display mode. However, some of these
1026 interactive commands are not available when running in Secure mode.
1027
1028 If you wish to know in advance whether or not your top has been
1029 secured, simply ask for help and view the system summary on the second
1030 line.
1031
1032
1033 <Enter> or <Space> :Refresh-Display
1034 These commands awaken top and following receipt of any input the
1035 entire display will be repainted. They also force an update of
1036 any hotplugged cpu or physical memory changes.
1037
1038 Use either of these keys if you have a large delay interval and
1039 wish to see current status,
1040
1041
1042 ? | h :Help
1043 There are two help levels available. The first will provide a
1044 reminder of all the basic interactive commands. If top is
1045 secured, that screen will be abbreviated.
1046
1047 Typing `h' or `?' on that help screen will take you to help for
1048 those interactive commands applicable to alternate-display mode.
1049
1050
1051 = :Exit-Display-Limits
1052 Removes restrictions on what is shown. This command will
1053 reverse any `i' (idle tasks), `n' (max tasks) and `v' (hide
1054 children) commands that might be active. It also provides for
1055 an exit from PID monitoring, User filtering, Other filtering,
1056 Locate processing and Combine Cpus mode.
1057
1058 Additionally, if the window has been scrolled it will be reset
1059 with this command.
1060
1061
1062 0 :Zero-Suppress toggle
1063 This command determines whether zeros are shown or suppressed
1064 for many of the fields in a task window. Fields like UID, GID,
1065 NI, PR or P are not affected by this toggle.
1066
1067
1068 A :Alternate-Display-Mode toggle
1069 This command will switch between full-screen mode and
1070 alternate-display mode. See topic 5. ALTERNATE-DISPLAY
1071 Provisions and the `g' interactive command for insight into
1072 `current' windows and field groups.
1073
1074
1075 B :Bold-Disable/Enable toggle
1076 This command will influence use of the bold terminfo capability
1077 and alters both the summary area and task area for the `current'
1078 window. While it is intended primarily for use with dumb
1079 terminals, it can be applied anytime.
1080
1081 Note: When this toggle is On and top is operating in monochrome
1082 mode, the entire display will appear as normal text. Thus,
1083 unless the `x' and/or `y' toggles are using reverse for
1084 emphasis, there will be no visual confirmation that they are
1085 even on.
1086
1087
1088 * d | s :Change-Delay-Time-interval
1089 You will be prompted to enter the delay time, in seconds,
1090 between display updates.
1091
1092 Fractional seconds are honored, but a negative number is not
1093 allowed. Entering 0 causes (nearly) continuous updates, with an
1094 unsatisfactory display as the system and tty driver try to keep
1095 up with top's demands. The delay value is inversely
1096 proportional to system loading, so set it with care.
1097
1098 If at any time you wish to know the current delay time, simply
1099 ask for help and view the system summary on the second line.
1100
1101
1102 E :Enforce-Summary-Memory-Scale in Summary Area
1103 With this command you can cycle through the available summary
1104 area memory scaling which ranges from KiB (kibibytes or 1,024
1105 bytes) through EiB (exbibytes or 1,152,921,504,606,846,976
1106 bytes).
1107
1108 If you see a `+' between a displayed number and the following
1109 label, it means that top was forced to truncate some portion of
1110 that number. By raising the scaling factor, such truncation can
1111 be avoided.
1112
1113
1114 e :Enforce-Task-Memory-Scale in Task Area
1115 With this command you can cycle through the available task area
1116 memory scaling which ranges from KiB (kibibytes or 1,024 bytes)
1117 through PiB (pebibytes or 1,125,899,906,842,624 bytes).
1118
1119 While top will try to honor the selected target range,
1120 additional scaling might still be necessary in order to
1121 accommodate current values. If you wish to see a more
1122 homogeneous result in the memory columns, raising the scaling
1123 range will usually accomplish that goal. Raising it too high,
1124 however, is likely to produce an all zero result which cannot be
1125 suppressed with the `0' interactive command.
1126
1127
1128 g :Choose-Another-Window/Field-Group
1129 You will be prompted to enter a number between 1 and 4
1130 designating the field group which should be made the `current'
1131 window. You will soon grow comfortable with these 4 windows,
1132 especially after experimenting with alternate-display mode.
1133
1134
1135 H :Threads-mode toggle
1136 When this toggle is On, individual threads will be displayed for
1137 all processes in all visible task windows. Otherwise, top
1138 displays a summation of all threads in each process.
1139
1140
1141 I :Irix/Solaris-Mode toggle
1142 When operating in Solaris mode (`I' toggled Off), a task's cpu
1143 usage will be divided by the total number of CPUs. After
1144 issuing this command, you'll be told the new state of this
1145 toggle.
1146
1147
1148 * k :Kill-a-task
1149 You will be prompted for a PID and then the signal to send.
1150
1151 Entering no PID or a negative number will be interpreted as the
1152 default shown in the prompt (the first task displayed). A PID
1153 value of zero means the top program itself.
1154
1155 The default signal, as reflected in the prompt, is SIGTERM.
1156 However, you can send any signal, via number or name.
1157
1158 If you wish to abort the kill process, do one of the following
1159 depending on your progress:
1160 1) at the pid prompt, type an invalid number
1161 2) at the signal prompt, type 0 (or any invalid signal)
1162 3) at any prompt, type <Esc>
1163
1164
1165 q :Quit
1166
1167
1168 * r :Renice-a-Task
1169 You will be prompted for a PID and then the value to nice it to.
1170
1171 Entering no PID or a negative number will be interpreted as the
1172 default shown in the prompt (the first task displayed). A PID
1173 value of zero means the top program itself.
1174
1175 A positive nice value will cause a process to lose priority.
1176 Conversely, a negative nice value will cause a process to be
1177 viewed more favorably by the kernel. As a general rule,
1178 ordinary users can only increase the nice value and are
1179 prevented from lowering it.
1180
1181 If you wish to abort the renice process, do one of the following
1182 depending on your progress:
1183 1) at the pid prompt, type an invalid number
1184 2) at the nice prompt, type <Enter> with no input
1185 3) at any prompt, type <Esc>
1186
1187
1188 W :Write-the-Configuration-File
1189 This will save all of your options and toggles plus the current
1190 display mode and delay time. By issuing this command just
1191 before quitting top, you will be able restart later in exactly
1192 that same state.
1193
1194
1195 X :Extra-Fixed-Width
1196 Some fields are fixed width and not scalable. As such, they are
1197 subject to truncation which would be indicated by a `+' in the
1198 last position.
1199
1200 This interactive command can be used to alter the widths of the
1201 following fields:
1202
1203 field default field default field default
1204 GID 5 GROUP 8 WCHAN 10
1205 RUID 5 LXC 8 nsIPC 10
1206 SUID 5 RUSER 8 nsMNT 10
1207 UID 5 SUSER 8 nsNET 10
1208 TTY 8 nsPID 10
1209 USER 8 nsUSER 10
1210 nsUTS 10
1211
1212 You will be prompted for the amount to be added to the default
1213 widths shown above. Entering zero forces a return to those
1214 defaults.
1215
1216 If you enter a negative number, top will automatically increase
1217 the column size as needed until there is no more truncated data.
1218 You can accelerate this process by reducing the delay interval
1219 or holding down the <Space> bar.
1220
1221 Note: Whether explicitly or automatically increased, the widths
1222 for these fields are never decreased by top. To narrow them you
1223 must specify a smaller number or restore the defaults.
1224
1225
1226 Y :Inspect-Other-Output
1227 After issuing the `Y' interactive command, you will be prompted
1228 for a target PID. Typing a value or accepting the default
1229 results in a separate screen. That screen can be used to view a
1230 variety of files or piped command output while the normal top
1231 iterative display is paused.
1232
1233 Note: This interactive command is only fully realized when
1234 supporting entries have been manually added to the end of the
1235 top configuration file. For details on creating those entries,
1236 see topic 6b. ADDING INSPECT Entries.
1237
1238 Most of the keys used to navigate the Inspect feature are
1239 reflected in its header prologue. There are, however,
1240 additional keys available once you have selected a particular
1241 file or command. They are familiar to anyone who has used the
1242 pager `less' and are summarized here for future reference.
1243
1244 key function
1245 = alternate status-line, file or pipeline
1246 / find, equivalent to `L' locate
1247 n find next, equivalent to `&' locate next
1248 <Space> scroll down, equivalent to <PgDn>
1249 b scroll up, equivalent to <PgUp>
1250 g first line, equivalent to <Home>
1251 G last line, equivalent to <End>
1252
1253
1254 Z :Change-Color-Mapping
1255 This key will take you to a separate screen where you can change
1256 the colors for the `current' window, or for all windows. For
1257 details regarding this interactive command see topic 4d. COLOR
1258 Mapping.
1259
1260
1261 * The commands shown with an asterisk (`*') are not available in
1262 Secure mode, nor will they be shown on the level-1 help screen.
1263
1264
1265 4b. SUMMARY AREA Commands
1266 The summary area interactive commands are always available in both
1267 full-screen mode and alternate-display mode. They affect the beginning
1268 lines of your display and will determine the position of messages and
1269 prompts.
1270
1271 These commands always impact just the `current' window/field group.
1272 See topic 5. ALTERNATE-DISPLAY Provisions and the `g' interactive
1273 command for insight into `current' windows and field groups.
1274
1275
1276 C :Show-scroll-coordinates toggle
1277 Toggle an informational message which is displayed whenever the
1278 message line is not otherwise being used. For additional
1279 information see topic 5c. SCROLLING a Window.
1280
1281
1282 l :Load-Average/Uptime toggle
1283 This is also the line containing the program name (possibly an
1284 alias) when operating in full-screen mode or the `current'
1285 window name when operating in alternate-display mode.
1286
1287
1288 t :Task/Cpu-States toggle
1289 This command affects from 2 to many summary area lines,
1290 depending on the state of the `1', `2' or `3' command toggles
1291 and whether or not top is running under true SMP.
1292
1293 This portion of the summary area is also influenced by the `H'
1294 interactive command toggle, as reflected in the total label
1295 which shows either Tasks or Threads.
1296
1297 This command serves as a 4-way toggle, cycling through these
1298 modes:
1299 1. detailed percentages by category
1300 2. abbreviated user/system and total % + bar graph
1301 3. abbreviated user/system and total % + block graph
1302 4. turn off task and cpu states display
1303
1304 When operating in either of the graphic modes, the display
1305 becomes much more meaningful when individual CPUs or NUMA nodes
1306 are also displayed. See the the `1', `2' and `3' commands below
1307 for additional information.
1308
1309
1310 m :Memory/Swap-Usage toggle
1311 This command affects the two summary area lines dealing with
1312 physical and virtual memory.
1313
1314 This command serves as a 4-way toggle, cycling through these
1315 modes:
1316 1. detailed percentages by memory type
1317 2. abbreviated % used/total available + bar graph
1318 3. abbreviated % used/total available + block graph
1319 4. turn off memory display
1320
1321
1322 1 :Single/Separate-Cpu-States toggle
1323 This command affects how the `t' command's Cpu States portion is
1324 shown. Although this toggle exists primarily to serve
1325 massively-parallel SMP machines, it is not restricted to solely
1326 SMP environments.
1327
1328 When you see `%Cpu(s):' in the summary area, the `1' toggle is
1329 On and all cpu information is gathered in a single line.
1330 Otherwise, each cpu is displayed separately as: `%Cpu0, %Cpu1,
1331 ...' up to available screen height.
1332
1333
1334 2 :NUMA-Nodes/Cpu-Summary toggle
1335 This command toggles between the `1' command cpu summary display
1336 (only) or a summary display plus the cpu usage statistics for
1337 each NUMA Node. It is only available if a system has the
1338 requisite NUMA support.
1339
1340
1341 3 :Expand-NUMA-Node
1342 You will be invited to enter a number representing a NUMA Node.
1343 Thereafter, a node summary plus the statistics for each cpu in
1344 that node will be shown until the `1', `2' or `4' command toggle
1345 is pressed. This interactive command is only available if a
1346 system has the requisite NUMA support.
1347
1348
1349 4 :Display-Cpus-Two-Abreast
1350 This command turns the `1' toggle Off for individual cpu display
1351 but prints the results two abreast. It requires a terminal with
1352 a minimum width of 80 columns. If a terminal's width is
1353 decreased below the minimum while top is running, top reverts to
1354 the normal `1' toggle Off state.
1355
1356 To avoid truncation when displaying detailed cpu statistcs, as
1357 opposed to the graphic representations, a minimum width of 165
1358 columns would be required.
1359
1360
1361 ! :Combine-Cpus-Mode
1362 This command toggle is intended for massively parallel SMP
1363 environments where, even with the `4' command toggle, not all
1364 processors can be displayed. With each press of `!' the number
1365 of additional cpu's combined is doubled thus reducing the total
1366 number of cpu lines displayed.
1367
1368 For example, with the first press of `!' one additional cpu will
1369 be combined and displayed as `0-1, 2-3, ...' instead of the
1370 normal `%Cpu0, %Cpu1, %Cpu2, %Cpu3, ...'. With a second `!'
1371 command toggle two additional cpus are combined and shown as
1372 `0-2, 3-5, ...'. Then the third '!' press, combining four
1373 additional cpus, shows as `0-4, 5-9, ...', etc.
1374
1375 Such progression continues until individual cpus are again
1376 displayed and impacts both the `1' and `4' toggles (one or two
1377 columns). Use the `=' command to exit Combine Cpus mode.
1378
1379
1380 Note: If the entire summary area has been toggled Off for any window,
1381 you would be left with just the message line. In that way, you will
1382 have maximized available task rows but (temporarily) sacrificed the
1383 program name in full-screen mode or the `current' window name when in
1384 alternate-display mode.
1385
1386
1387 4c. TASK AREA Commands
1388 The task area interactive commands are always available in full-screen
1389 mode.
1390
1391 The task area interactive commands are never available in
1392 alternate-display mode if the `current' window's task display has been
1393 toggled Off (see topic 5. ALTERNATE-DISPLAY Provisions).
1394
1395
1396 APPEARANCE of task window
1397
1398
1399 J :Justify-Numeric-Columns toggle
1400 Alternates between right-justified (the default) and left-
1401 justified numeric data. If the numeric data completely fills
1402 the available column, this command toggle may impact the column
1403 header only.
1404
1405
1406 j :Justify-Character-Columns toggle
1407 Alternates between left-justified (the default) and right-
1408 justified character data. If the character data completely
1409 fills the available column, this command toggle may impact the
1410 column header only.
1411
1412
1413 The following commands will also be influenced by the state of the
1414 global `B' (bold enable) toggle.
1415
1416
1417 b :Bold/Reverse toggle
1418 This command will impact how the `x' and `y' toggles are
1419 displayed. It may also impact the summary area when a bar graph
1420 has been selected for cpu states or memory usage via the `t' or
1421 `m' toggles.
1422
1423
1424 x :Column-Highlight toggle
1425 Changes highlighting for the current sort field. If you forget
1426 which field is being sorted this command can serve as a quick
1427 visual reminder, providing the sort field is being displayed.
1428 The sort field might not be visible because:
1429 1) there is insufficient Screen Width
1430 2) the `f' interactive command turned it Off
1431
1432 Note: Whenever Searching and/or Other Filtering is active in a
1433 window, column highlighting is temporarily disabled. See the
1434 notes at the end of topics 5d. SEARCHING and 5e. FILTERING for
1435 an explanation why.
1436
1437
1438 y :Row-Highlight toggle
1439 Changes highlighting for "running" tasks. For additional
1440 insight into this task state, see topic 3a. DESCRIPTIONS of
1441 Fields, the `S' field (Process Status).
1442
1443 Use of this provision provides important insight into your
1444 system's health. The only costs will be a few additional tty
1445 escape sequences.
1446
1447
1448 z :Color/Monochrome toggle
1449 Switches the `current' window between your last used color
1450 scheme and the older form of black-on-white or white-on-black.
1451 This command will alter both the summary area and task area but
1452 does not affect the state of the `x', `y' or `b' toggles.
1453
1454
1455 CONTENT of task window
1456
1457
1458 c :Command-Line/Program-Name toggle
1459 This command will be honored whether or not the COMMAND column
1460 is currently visible. Later, should that field come into view,
1461 the change you applied will be seen.
1462
1463
1464 f | F :Fields-Management
1465 These keys display a separate screen where you can change which
1466 fields are displayed, their order and also designate the sort
1467 field. For additional information on these interactive commands
1468 see topic 3b. MANAGING Fields.
1469
1470
1471 o | O :Other-Filtering
1472 You will be prompted for the selection criteria which then
1473 determines which tasks will be shown in the `current' window.
1474 Your criteria can be made case sensitive or case can be ignored.
1475 And you determine if top should include or exclude matching
1476 tasks.
1477
1478 See topic 5e. FILTERING in a window for details on these and
1479 additional related interactive commands.
1480
1481
1482 S :Cumulative-Time-Mode toggle
1483 When Cumulative mode is On, each process is listed with the cpu
1484 time that it and its dead children have used.
1485
1486 When Off, programs that fork into many separate tasks will
1487 appear less demanding. For programs like `init' or a shell this
1488 is appropriate but for others, like compilers, perhaps not.
1489 Experiment with two task windows sharing the same sort field but
1490 with different `S' states and see which representation you
1491 prefer.
1492
1493 After issuing this command, you'll be informed of the new state
1494 of this toggle. If you wish to know in advance whether or not
1495 Cumulative mode is in effect, simply ask for help and view the
1496 window summary on the second line.
1497
1498
1499 u | U :Show-Specific-User-Only
1500 You will be prompted for the uid or name of the user to display.
1501 The -u option matches on effective user whereas the -U option
1502 matches on any user (real, effective, saved, or filesystem).
1503
1504 Thereafter, in that task window only matching users will be
1505 shown, or possibly no processes will be shown. Prepending an
1506 exclamation point (`!') to the user id or name instructs top to
1507 display only processes with users not matching the one provided.
1508
1509 Different task windows can be used to filter different users.
1510 Later, if you wish to monitor all users again in the `current'
1511 window, re-issue this command but just press <Enter> at the
1512 prompt.
1513
1514
1515 V :Forest-View-Mode toggle
1516 In this mode, processes are reordered according to their parents
1517 and the layout of the COMMAND column resembles that of a tree.
1518 In forest view mode it is still possible to toggle between
1519 program name and command line (see the `c' interactive command)
1520 or between processes and threads (see the `H' interactive
1521 command).
1522
1523 Note: Typing any key affecting the sort order will exit forest
1524 view mode in the `current' window. See topic 4c. TASK AREA
1525 Commands, SORTING for information on those keys.
1526
1527
1528 v :Hide/Show-Children toggle
1529 When in forest view mode, this key serves as a toggle to
1530 collapse or expand the children of a parent.
1531
1532 The toggle is applied against the first (topmost) process in the
1533 `current' window. See topic 5c. SCROLLING a Window for
1534 additional information regarding vertical scrolling.
1535
1536 If the target process has not forked any children, this key has
1537 no effect. It also has no effect when not in forest view mode.
1538
1539
1540 SIZE of task window
1541
1542
1543 i :Idle-Process toggle
1544 Displays all tasks or just active tasks. When this toggle is
1545 Off, tasks that have not used any CPU since the last update will
1546 not be displayed. However, due to the granularity of the %CPU
1547 and TIME+ fields, some processes may still be displayed that
1548 appear to have used no CPU.
1549
1550 If this command is applied to the last task display when in
1551 alternate-display mode, then it will not affect the window's
1552 size, as all prior task displays will have already been painted.
1553
1554
1555 n | # :Set-Maximum-Tasks
1556 You will be prompted to enter the number of tasks to display.
1557 The lessor of your number and available screen rows will be
1558 used.
1559
1560 When used in alternate-display mode, this is the command that
1561 gives you precise control over the size of each currently
1562 visible task display, except for the very last. It will not
1563 affect the last window's size, as all prior task displays will
1564 have already been painted.
1565
1566 Note: If you wish to increase the size of the last visible task
1567 display when in alternate-display mode, simply decrease the size
1568 of the task display(s) above it.
1569
1570
1571 SORTING of task window
1572
1573 For compatibility, this top supports most of the former top sort
1574 keys. Since this is primarily a service to former top users, these
1575 commands do not appear on any help screen.
1576 command sorted-field supported
1577 A start time (non-display) No
1578 M %MEM Yes
1579 N PID Yes
1580 P %CPU Yes
1581 T TIME+ Yes
1582
1583 Before using any of the following sort provisions, top suggests that
1584 you temporarily turn on column highlighting using the `x'
1585 interactive command. That will help ensure that the actual sort
1586 environment matches your intent.
1587
1588 The following interactive commands will only be honored when the
1589 current sort field is visible. The sort field might not be visible
1590 because:
1591 1) there is insufficient Screen Width
1592 2) the `f' interactive command turned it Off
1593
1594
1595 < :Move-Sort-Field-Left
1596 Moves the sort column to the left unless the current sort
1597 field is the first field being displayed.
1598
1599
1600 > :Move-Sort-Field-Right
1601 Moves the sort column to the right unless the current sort
1602 field is the last field being displayed.
1603
1604
1605 The following interactive commands will always be honored whether or
1606 not the current sort field is visible.
1607
1608
1609 f | F :Fields-Management
1610 These keys display a separate screen where you can change
1611 which field is used as the sort column, among other
1612 functions. This can be a convenient way to simply verify the
1613 current sort field, when running top with column highlighting
1614 turned Off.
1615
1616
1617 R :Reverse/Normal-Sort-Field toggle
1618 Using this interactive command you can alternate between
1619 high-to-low and low-to-high sorts.
1620
1621
1622 Note: Field sorting uses internal values, not those in column
1623 display. Thus, the TTY and WCHAN fields will violate strict ASCII
1624 collating sequence.
1625
1626
1627 4d. COLOR Mapping
1628 When you issue the `Z' interactive command, you will be presented with
1629 a separate screen. That screen can be used to change the colors in
1630 just the `current' window or in all four windows before returning to
1631 the top display.
1632
1633
1634 The following interactive commands are available.
1635 4 upper case letters to select a target
1636 8 numbers to select a color
1637 normal toggles available
1638 B :bold disable/enable
1639 b :running tasks "bold"/reverse
1640 z :color/mono
1641 other commands available
1642 a/w :apply, then go to next/prior
1643 <Enter> :apply and exit
1644 q :abandon current changes and exit
1645
1646 If you use `a' or `w' to cycle the targeted window, you will have
1647 applied the color scheme that was displayed when you left that window.
1648 You can, of course, easily return to any window and reapply different
1649 colors or turn colors Off completely with the `z' toggle.
1650
1651 The Color Mapping screen can also be used to change the `current'
1652 window/field group in either full-screen mode or alternate-display
1653 mode. Whatever was targeted when `q' or <Enter> was pressed will be
1654 made current as you return to the top display.
1655
1656
1658 5a. WINDOWS Overview
1659 Field Groups/Windows:
1660 In full-screen mode there is a single window represented by the
1661 entire screen. That single window can still be changed to display 1
1662 of 4 different field groups (see the `g' interactive command,
1663 repeated below). Each of the 4 field groups has a unique separately
1664 configurable summary area and its own configurable task area.
1665
1666 In alternate-display mode, those 4 underlying field groups can now
1667 be made visible simultaneously, or can be turned Off individually at
1668 your command.
1669
1670 The summary area will always exist, even if it's only the message
1671 line. At any given time only one summary area can be displayed.
1672 However, depending on your commands, there could be from zero to
1673 four separate task displays currently showing on the screen.
1674
1675
1676 Current Window:
1677 The `current' window is the window associated with the summary area
1678 and the window to which task related commands are always directed.
1679 Since in alternate-display mode you can toggle the task display Off,
1680 some commands might be restricted for the `current' window.
1681
1682 A further complication arises when you have toggled the first
1683 summary area line Off. With the loss of the window name (the `l'
1684 toggled line), you'll not easily know what window is the `current'
1685 window.
1686
1687
1688 5b. COMMANDS for Windows
1689 - | _ :Show/Hide-Window(s) toggles
1690 The `-' key turns the `current' window's task display On and
1691 Off. When On, that task area will show a minimum of the columns
1692 header you've established with the `f' interactive command. It
1693 will also reflect any other task area options/toggles you've
1694 applied yielding zero or more tasks.
1695
1696 The `_' key does the same for all task displays. In other
1697 words, it switches between the currently visible task display(s)
1698 and any task display(s) you had toggled Off. If all 4 task
1699 displays are currently visible, this interactive command will
1700 leave the summary area as the only display element.
1701
1702
1703 * = | + :Equalize/Reset-Window(s)
1704 The `=' key forces the `current' window's task display to be
1705 visible. It also reverses any active `i' (idle tasks), `n' (max
1706 tasks), `u/U' (user filter), `o/O' (other filter), `v' (hide
1707 children), `L' (locate) and `!' (combine cpus) commands. Also,
1708 if the window had been scrolled, it will be reset with this
1709 command. See topic 5c. SCROLLING a Window for additional
1710 information regarding vertical and horizontal scrolling.
1711
1712 The `+' key does the same for all windows. The four task
1713 displays will reappear, evenly balanced, while retaining any
1714 customizations previously applied beyond those noted for the `='
1715 command toggle.
1716
1717
1718 * A :Alternate-Display-Mode toggle
1719 This command will switch between full-screen mode and
1720 alternate-display mode.
1721
1722 The first time you issue this command, all four task displays
1723 will be shown. Thereafter when you switch modes, you will see
1724 only the task display(s) you've chosen to make visible.
1725
1726
1727 * a | w :Next-Window-Forward/Backward
1728 This will change the `current' window, which in turn changes the
1729 window to which commands are directed. These keys act in a
1730 circular fashion so you can reach any desired window using
1731 either key.
1732
1733 Assuming the window name is visible (you have not toggled `l'
1734 Off), whenever the `current' window name loses its
1735 emphasis/color, that's a reminder the task display is Off and
1736 many commands will be restricted.
1737
1738
1739 * g :Choose-Another-Window/Field-Group
1740 You will be prompted to enter a number between 1 and 4
1741 designating the field group which should be made the `current'
1742 window.
1743
1744 In full-screen mode, this command is necessary to alter the
1745 `current' window. In alternate-display mode, it is simply a
1746 less convenient alternative to the `a' and `w' commands.
1747
1748
1749 G :Change-Window/Field-Group-Name
1750 You will be prompted for a new name to be applied to the
1751 `current' window. It does not require that the window name be
1752 visible (the `l' toggle to be On).
1753
1754
1755 * The interactive commands shown with an asterisk (`*') have use
1756 beyond alternate-display mode.
1757 =, A, g are always available
1758 a, w act the same with color mapping
1759 and fields management
1760
1761
1762 5c. SCROLLING a Window
1763 Typically a task window is a partial view into a systems's total
1764 tasks/threads which shows only some of the available fields/columns.
1765 With these scrolling keys, you can move that view vertically or
1766 horizontally to reveal any desired task or column.
1767
1768
1769 Up,PgUp :Scroll-Tasks
1770 Move the view up toward the first task row, until the first task is
1771 displayed at the top of the `current' window. The Up arrow key
1772 moves a single line while PgUp scrolls the entire window.
1773
1774
1775 Down,PgDn :Scroll-Tasks
1776 Move the view down toward the last task row, until the last task is
1777 the only task displayed at the top of the `current' window. The
1778 Down arrow key moves a single line while PgDn scrolls the entire
1779 window.
1780
1781
1782 Left,Right :Scroll-Columns
1783 Move the view of displayable fields horizontally one column at a
1784 time.
1785
1786 Note: As a reminder, some fields/columns are not fixed-width but
1787 allocated all remaining screen width when visible. When scrolling
1788 right or left, that feature may produce some unexpected results
1789 initially.
1790
1791 Additionally, there are special provisions for any variable width
1792 field when positioned as the last displayed field. Once that field
1793 is reached via the right arrow key, and is thus the only column
1794 shown, you can continue scrolling horizontally within such a field.
1795 See the `C' interactive command below for additional information.
1796
1797
1798 Home :Jump-to-Home-Position
1799 Reposition the display to the un-scrolled coordinates.
1800
1801
1802 End :Jump-to-End-Position
1803 Reposition the display so that the rightmost column reflects the
1804 last displayable field and the bottom task row represents the last
1805 task.
1806
1807 Note: From this position it is still possible to scroll down and
1808 right using the arrow keys. This is true until a single column and
1809 a single task is left as the only display element.
1810
1811
1812 C :Show-scroll-coordinates toggle
1813 Toggle an informational message which is displayed whenever the
1814 message line is not otherwise being used. That message will take
1815 one of two forms depending on whether or not a variable width
1816 column has also been scrolled.
1817
1818 scroll coordinates: y = n/n (tasks), x = n/n (fields)
1819 scroll coordinates: y = n/n (tasks), x = n/n (fields) + nn
1820
1821 The coordinates shown as n/n are relative to the upper left corner
1822 of the `current' window. The additional `+ nn' represents the
1823 displacement into a variable width column when it has been scrolled
1824 horizontally. Such displacement occurs in normal 8 character tab
1825 stop amounts via the right and left arrow keys.
1826
1827
1828 y = n/n (tasks)
1829 The first n represents the topmost visible task and is
1830 controlled by scrolling keys. The second n is updated
1831 automatically to reflect total tasks.
1832
1833
1834 x = n/n (fields)
1835 The first n represents the leftmost displayed column and is
1836 controlled by scrolling keys. The second n is the total number
1837 of displayable fields and is established with the `f'
1838 interactive command.
1839
1840
1841 The above interactive commands are always available in full-screen mode
1842 but never available in alternate-display mode if the `current' window's
1843 task display has been toggled Off.
1844
1845 Note: When any form of filtering is active, you can expect some slight
1846 aberrations when scrolling since not all tasks will be visible. This
1847 is particularly apparent when using the Up/Down arrow keys.
1848
1849
1850 5d. SEARCHING in a Window
1851 You can use these interactive commands to locate a task row containing
1852 a particular value.
1853
1854
1855 L :Locate-a-string
1856 You will be prompted for the case-sensitive string to locate
1857 starting from the current window coordinates. There are no
1858 restrictions on search string content.
1859
1860 Searches are not limited to values from a single field or column.
1861 All of the values displayed in a task row are allowed in a search
1862 string. You may include spaces, numbers, symbols and even forest
1863 view artwork.
1864
1865 Keying <Enter> with no input will effectively disable the `&' key
1866 until a new search string is entered.
1867
1868
1869 & :Locate-next
1870 Assuming a search string has been established, top will attempt to
1871 locate the next occurrence.
1872
1873
1874 When a match is found, the current window is repositioned vertically so
1875 the task row containing that string is first. The scroll coordinates
1876 message can provide confirmation of such vertical repositioning (see
1877 the `C' interactive command). Horizontal scrolling, however, is never
1878 altered via searching.
1879
1880 The availability of a matching string will be influenced by the
1881 following factors.
1882
1883 a. Which fields are displayable from the total available,
1884 see topic 3b. MANAGING Fields.
1885
1886 b. Scrolling a window vertically and/or horizontally,
1887 see topic 5c. SCROLLING a Window.
1888
1889 c. The state of the command/command-line toggle,
1890 see the `c' interactive command.
1891
1892 d. The stability of the chosen sort column,
1893 for example PID is good but %CPU bad.
1894
1895
1896 If a search fails, restoring the `current' window home (unscrolled)
1897 position, scrolling horizontally, displaying command-lines or choosing
1898 a more stable sort field could yet produce a successful `&' search.
1899
1900 The above interactive commands are always available in full-screen mode
1901 but never available in alternate-display mode if the `current' window's
1902 task display has been toggled Off.
1903
1904 Note: Whenever a Search is active in a window, top will turn column
1905 highlighting Off to prevent false matches on internal non-display
1906 escape sequences. Such highlighting will be restored when a window's
1907 search string is empty. See the `x' interactive command for additional
1908 information on sort column highlighting.
1909
1910
1911 5e. FILTERING in a Window
1912 You can use this `Other Filter' feature to establish selection criteria
1913 which will then determine which tasks are shown in the `current'
1914 window. Such filters can be made presistent if preserved in the rcfile
1915 via the 'W' interactive command.
1916
1917 Establishing a filter requires: 1) a field name; 2) an operator; and 3)
1918 a selection value, as a minimum. This is the most complex of top's
1919 user input requirements so, when you make a mistake, command recall
1920 will be your friend. Remember the Up/Down arrow keys or their aliases
1921 when prompted for input.
1922
1923 Filter Basics
1924
1925 1. field names are case sensitive and spelled as in the header
1926
1927 2. selection values need not comprise the full displayed field
1928
1929 3. a selection is either case insensitive or sensitive to case
1930
1931 4. the default is inclusion, prepending `!' denotes exclusions
1932
1933 5. multiple selection criteria can be applied to a task window
1934
1935 6. inclusion and exclusion criteria can be used simultaneously
1936
1937 7. the 1 equality and 2 relational filters can be freely mixed
1938
1939 8. separate unique filters are maintained for each task window
1940
1941
1942 If a field is not turned on or is not currently in view, then your
1943 selection criteria will not affect the display. Later, should a
1944 filtered field become visible, the selection criteria will then be
1945 applied.
1946
1947 Keyboard Summary
1948
1949 o :Other-Filter (lower case)
1950 You will be prompted to establish a filter that ignores case when
1951 matching.
1952
1953
1954 O :Other-Filter (upper case)
1955 You will be prompted to establish a case sensitive filter.
1956
1957
1958 ^O :Show-Active-Filters (Ctrl key + `o')
1959 This can serve as a reminder of which filters are active in the
1960 `current' window. A summary will be shown on the message line
1961 until you press the <Enter> key.
1962
1963
1964 = :Reset-Filtering in current window
1965 This clears all of your selection criteria in the `current'
1966 window. It also has additional impact so please see topic 4a.
1967 GLOBAL Commands.
1968
1969
1970 + :Reset-Filtering in all windows
1971 This clears the selection criteria in all windows, assuming you
1972 are in alternate-display mode. As with the `=' interactive
1973 command, it too has additional consequences so you might wish to
1974 see topic 5b. COMMANDS for Windows.
1975
1976
1977 Input Requirements
1978
1979 When prompted for selection criteria, the data you provide must take
1980 one of two forms. There are 3 required pieces of information, with
1981 a 4th as optional. These examples use spaces for clarity but your
1982 input generally would not.
1983 #1 #2 #3 ( required )
1984 Field-Name ? include-if-value
1985 ! Field-Name ? exclude-if-value
1986 #4 ( optional )
1987
1988 Items #1, #3 and #4 should be self-explanatory. Item #2 represents
1989 both a required delimiter and the operator which must be one of
1990 either equality (`=') or relation (`<' or `>').
1991
1992 The `=' equality operator requires only a partial match and that can
1993 reduce your `if-value' input requirements. The `>' or `<'
1994 relational operators always employ string comparisons, even with
1995 numeric fields. They are designed to work with a field's default
1996 justification and with homogeneous data. When some field's numeric
1997 amounts have been subjected to scaling while others have not, that
1998 data is no longer homogeneous.
1999
2000 If you establish a relational filter and you have changed the
2001 default Numeric or Character justification, that filter is likely to
2002 fail. When a relational filter is applied to a memory field and you
2003 have not changed the scaling, it may produce misleading results.
2004 This happens, for example, because `100.0m' (MiB) would appear
2005 greater than `1.000g' (GiB) when compared as strings.
2006
2007 If your filtered results appear suspect, simply altering
2008 justification or scaling may yet achieve the desired objective. See
2009 the `j', `J' and `e' interactive commands for additional
2010 information.
2011
2012 Potential Problems
2013
2014 These GROUP filters could produce the exact same results or the
2015 second one might not display anything at all, just a blank task
2016 window.
2017 GROUP=root ( only the same results when )
2018 GROUP=ROOT ( invoked via lower case `o' )
2019
2020 Either of these RES filters might yield inconsistent and/or
2021 misleading results, depending on the current memory scaling factor.
2022 Or both filters could produce the exact same results.
2023 RES>9999 ( only the same results when )
2024 !RES<10000 ( memory scaling is at `KiB' )
2025
2026 This nMin filter illustrates a problem unique to scalable fields.
2027 This particular field can display a maximum of 4 digits, beyond
2028 which values are automatically scaled to KiB or above. So while
2029 amounts greater than 9999 exist, they will appear as 2.6m, 197k,
2030 etc.
2031 nMin>9999 ( always a blank task window )
2032
2033 Potential Solutions
2034
2035 These examples illustrate how Other Filtering can be creatively
2036 applied to achieve almost any desired result. Single quotes are
2037 sometimes shown to delimit the spaces which are part of a filter or
2038 to represent a request for status (^O) accurately. But if you used
2039 them with if-values in real life, no matches would be found.
2040
2041 Assuming field nTH is displayed, the first filter will result in
2042 only multi-threaded processes being shown. It also reminds us that
2043 a trailing space is part of every displayed field. The second
2044 filter achieves the exact same results with less typing.
2045 !nTH=` 1 ' ( ' for clarity only )
2046 nTH>1 ( same with less i/p )
2047
2048 With Forest View mode active and the COMMAND column in view, this
2049 filter effectively collapses child processes so that just 3 levels
2050 are shown.
2051 !COMMAND=` `- ' ( ' for clarity only )
2052
2053 The final two filters appear as in response to the status request
2054 key (^O). In reality, each filter would have required separate
2055 input. The PR example shows the two concurrent filters necessary to
2056 display tasks with priorities of 20 or more, since some might be
2057 negative. Then by exploiting trailing spaces, the nMin series of
2058 filters could achieve the failed `9999' objective discussed above.
2059 `PR>20' + `!PR=-' ( 2 for right result )
2060 `!nMin=0 ' + `!nMin=1 ' + `!nMin=2 ' + `!nMin=3 ' ...
2061
2062 Note: Whenever Other Filtering is active in a window, top will turn
2063 column highlighting Off to prevent false matches on internal non-
2064 display escape sequences. Such highlighting will be restored when a
2065 window is no longer subject to filtering. See the `x' interactive
2066 command for additional information on sort column highlighting.
2067
2068
2070 6a. PERSONAL Configuration File
2071 This file is created or updated via the 'W' interactive command.
2072
2073 The legacy version is written as `$HOME/.your-name-4-top' + `rc' with a
2074 leading period.
2075
2076 A newly created configuration file is written as
2077 procps/your-name-4-top' + `rc' without a leading period. The procps
2078 directory will be subordinate to either $XDG_CONFIG_HOME when set as an
2079 absolute path or the $HOME/.config directory.
2080
2081 While not intended to be edited manually, here is the general layout:
2082 global # line 1: the program name/alias notation
2083 " # line 2: id,altscr,irixps,delay,curwin
2084 per ea # line a: winname,fieldscur
2085 window # line b: winflags,sortindx,maxtasks,etc
2086 " # line c: summclr,msgsclr,headclr,taskclr
2087 global # line 15: additional miscellaneous settings
2088 " # any remaining lines are devoted to optional
2089 " # active 'other filters' discussed in section 5e above
2090 " # plus 'inspect' entries discussed in section 6b below
2091
2092 If a valid absolute path to the rcfile cannot be established,
2093 customizations made to a running top will be impossible to preserve.
2094
2095
2096 6b. ADDING INSPECT Entries
2097 To exploit the `Y' interactive command, you must add entries at the end
2098 of the top personal configuration file. Such entries simply reflect a
2099 file to be read or command/pipeline to be executed whose results will
2100 then be displayed in a separate scrollable, searchable window.
2101
2102 If you don't know the location or name of your top rcfile, use the `W'
2103 interactive command to rewrite it and note those details.
2104
2105 Inspect entries can be added with a redirected echo or by editing the
2106 configuration file. Redirecting an echo risks overwriting the rcfile
2107 should it replace (>) rather than append (>>) to that file.
2108 Conversely, when using an editor care must be taken not to corrupt
2109 existing lines, some of which will contain unprintable data or unusual
2110 characters.
2111
2112 Those Inspect entries beginning with a `#' character are ignored,
2113 regardless of content. Otherwise they consist of the following 3
2114 elements, each of which must be separated by a tab character (thus 2
2115 `\t' total):
2116
2117 .type: literal `file' or `pipe'
2118 .name: selection shown on the Inspect screen
2119 .fmts: string representing a path or command
2120
2121 The two types of Inspect entries are not interchangeable. Those
2122 designated `file' will be accessed using fopen and must reference a
2123 single file in the `.fmts' element. Entries specifying `pipe' will
2124 employ popen, their `.fmts' element could contain many pipelined
2125 commands and, none can be interactive.
2126
2127 If the file or pipeline represented in your `.fmts' deals with the
2128 specific PID input or accepted when prompted, then the format string
2129 must also contain the `%d' specifier, as these examples illustrate.
2130
2131 .fmts= /proc/%d/numa_maps
2132 .fmts= lsof -P -p %d
2133
2134 For `pipe' type entries only, you may also wish to redirect stderr to
2135 stdout for a more comprehensive result. Thus the format string
2136 becomes:
2137
2138 .fmts= pmap -x %d 2>&1
2139
2140 Here are examples of both types of Inspect entries as they might appear
2141 in the rcfile. The first entry will be ignored due to the initial `#'
2142 character. For clarity, the pseudo tab depictions (^I) are surrounded
2143 by an extra space but the actual tabs would not be.
2144
2145 # pipe ^I Sockets ^I lsof -n -P -i 2>&1
2146 pipe ^I Open Files ^I lsof -P -p %d 2>&1
2147 file ^I NUMA Info ^I /proc/%d/numa_maps
2148 pipe ^I Log ^I tail -n100 /var/log/syslog | sort -Mr
2149
2150 Except for the commented entry above, these next examples show what
2151 could be echoed to achieve similar results, assuming the rcfile name
2152 was `.toprc'. However, due to the embedded tab characters, each of
2153 these lines should be preceded by `/bin/echo -e', not just a simple an
2154 `echo', to enable backslash interpretation regardless of which shell
2155 you use.
2156
2157 "pipe\tOpen Files\tlsof -P -p %d 2>&1" >> ~/.toprc
2158 "file\tNUMA Info\t/proc/%d/numa_maps" >> ~/.toprc
2159 "pipe\tLog\ttail -n200 /var/log/syslog | sort -Mr" >> ~/.toprc
2160
2161 If any inspect entry you create produces output with unprintable
2162 characters they will be displayed in either the ^C notation or
2163 hexadecimal <FF> form, depending on their value. This applies to tab
2164 characters as well, which will show as `^I'. If you want a truer
2165 representation, any embedded tabs should be expanded. The following
2166 example takes what could have been a `file' entry but employs a `pipe'
2167 instead so as to expand the embedded tabs.
2168
2169 # next would have contained `\t' ...
2170 # file ^I <your_name> ^I /proc/%d/status
2171 # but this will eliminate embedded `\t' ...
2172 pipe ^I <your_name> ^I cat /proc/%d/status | expand -
2173
2174 Note: Some programs might rely on SIGINT to end. Therefore, if a
2175 `pipe' such as the following is established, one must use Ctrl-C to
2176 terminate it in order to review the results. This is the single
2177 occasion where a `^C' will not also terminate top.
2178
2179 pipe ^I Trace ^I /usr/bin/strace -p %d 2>&1
2180
2181 Lastly, while `pipe' type entries have been discussed in terms of
2182 pipelines and commands, there is nothing to prevent you from including
2183 shell scripts as well. Perhaps even newly created scripts designed
2184 specifically for the `Y' interactive command.
2185
2186 For example, as the number of your Inspect entries grows over time, the
2187 `Options:' row will be truncated when screen width is exceeded. That
2188 does not affect operation other than to make some selections invisible.
2189 However, if some choices are lost to truncation but you want to see
2190 more options, there is an easy solution hinted at below.
2191
2192 Inspection Pause at pid ...
2193 Use: left/right then <Enter> ...
2194 Options: help 1 2 3 4 5 6 7 8 9 10 11 ...
2195
2196 The entries in the top rcfile would have a number for the `.name'
2197 element and the `help' entry would identify a shell script you've
2198 written explaining what those numbered selections actually mean. In
2199 that way, many more choices can be made visible.
2200
2201
2202 6c. SYSTEM Configuration File
2203 This configuration file represents defaults for users who have not
2204 saved their own configuration file. The format mirrors exactly the
2205 personal configuration file and can also include `inspect' entries as
2206 explained above.
2207
2208 Creating it is a simple process.
2209
2210 1. Configure top appropriately for your installation and preserve that
2211 configuration with the `W' interactive command.
2212
2213 2. Add and test any desired `inspect' entries.
2214
2215 3. Copy that configuration file to the /etc/ directory as
2216 `topdefaultrc'.
2217
2218
2219 6d. SYSTEM Restrictions File
2220 The presence of this file will influence which version of the help
2221 screen is shown to an ordinary user.
2222
2223 More importantly, it will limit what ordinary users are allowed to do
2224 when top is running. They will not be able to issue the following
2225 commands.
2226 k Kill a task
2227 r Renice a task
2228 d or s Change delay/sleep interval
2229
2230 This configuration file is not created by top. Rather, it is created
2231 manually and placed it in the /etc/ directory as `toprc'.
2232
2233 It should have exactly two lines, as shown in this example:
2234 s # line 1: secure mode switch
2235 5.0 # line 2: delay interval in seconds
2236
2237
2239 Many of these tricks work best when you give top a scheduling boost.
2240 So plan on starting him with a nice value of -10, assuming you've got
2241 the authority.
2242
2243
2244 7a. Kernel Magic
2245 For these stupid tricks, top needs full-screen mode.
2246
2247
2248 • The user interface, through prompts and help, intentionally implies
2249 that the delay interval is limited to tenths of a second. However,
2250 you're free to set any desired delay. If you want to see Linux at
2251 his scheduling best, try a delay of .09 seconds or less.
2252
2253 For this experiment, under x-windows open an xterm and maximize it.
2254 Then do the following:
2255 . provide a scheduling boost and tiny delay via:
2256 nice -n -10 top -d.09
2257 . keep sorted column highlighting Off so as to
2258 minimize path length
2259 . turn On reverse row highlighting for emphasis
2260 . try various sort columns (TIME/MEM work well),
2261 and normal or reverse sorts to bring the most
2262 active processes into view
2263
2264 What you'll see is a very busy Linux doing what he's always done for
2265 you, but there was no program available to illustrate this.
2266
2267
2268 • Under an xterm using `white-on-black' colors, on top's Color Mapping
2269 screen set the task color to black and be sure that task
2270 highlighting is set to bold, not reverse. Then set the delay
2271 interval to around .3 seconds.
2272
2273 After bringing the most active processes into view, what you'll see
2274 are the ghostly images of just the currently running tasks.
2275
2276
2277 • Delete the existing rcfile, or create a new symlink. Start this new
2278 version then type `T' (a secret key, see topic 4c. Task Area
2279 Commands, SORTING) followed by `W' and `q'. Finally, restart the
2280 program with -d0 (zero delay).
2281
2282 Your display will be refreshed at three times the rate of the former
2283 top, a 300% speed advantage. As top climbs the TIME ladder, be as
2284 patient as you can while speculating on whether or not top will ever
2285 reach the top.
2286
2287
2288 7b. Bouncing Windows
2289 For these stupid tricks, top needs alternate-display mode.
2290
2291
2292 • With 3 or 4 task displays visible, pick any window other than the
2293 last and turn idle processes Off using the `i' command toggle.
2294 Depending on where you applied `i', sometimes several task displays
2295 are bouncing and sometimes it's like an accordion, as top tries his
2296 best to allocate space.
2297
2298
2299 • Set each window's summary lines differently: one with no memory
2300 (`m'); another with no states (`t'); maybe one with nothing at all,
2301 just the message line. Then hold down `a' or `w' and watch a
2302 variation on bouncing windows -- hopping windows.
2303
2304
2305 • Display all 4 windows and for each, in turn, set idle processes to
2306 Off using the `i' command toggle. You've just entered the "extreme
2307 bounce" zone.
2308
2309
2310 7c. The Big Bird Window
2311 This stupid trick also requires alternate-display mode.
2312
2313
2314 • Display all 4 windows and make sure that 1:Def is the `current'
2315 window. Then, keep increasing window size with the `n' interactive
2316 command until all the other task displays are "pushed out of the
2317 nest".
2318
2319 When they've all been displaced, toggle between all
2320 visible/invisible windows using the `_' command toggle. Then ponder
2321 this:
2322 is top fibbing or telling honestly your imposed truth?
2323
2324
2325 7d. The Ol' Switcheroo
2326 This stupid trick works best without alternate-display mode, since
2327 justification is active on a per window basis.
2328
2329
2330 • Start top and make COMMAND the last (rightmost) column displayed.
2331 If necessary, use the `c' command toggle to display command lines
2332 and ensure that forest view mode is active with the `V' command
2333 toggle.
2334
2335 Then use the up/down arrow keys to position the display so that some
2336 truncated command lines are shown (`+' in last position). You may
2337 have to resize your xterm to produce truncation.
2338
2339 Lastly, use the `j' command toggle to make the COMMAND column right
2340 justified.
2341
2342 Now use the right arrow key to reach the COMMAND column. Continuing
2343 with the right arrow key, watch closely the direction of travel for
2344 the command lines being shown.
2345
2346 some lines travel left, while others travel right
2347
2348 eventually all lines will Switcheroo, and move right
2349
2350
2352 Please send bug reports to ⟨procps@freelists.org⟩.
2353
2354
2355
2357 free(1), ps(1), uptime(1), atop(1), slabtop(1), vmstat(8), w(1)
2358
2359
2360
2361procps-ng September 2020 TOP(1)