Top (software) explained

top
Screenshot Size:300px
Author:William LeFebvre
Genre:Process viewer / System monitor
Website:hide
Operating System:Unix-like
Programming Language:C

top (table of processes) is a task manager or system monitor program, found in many Unix-like operating systems, that displays information about CPU and memory utilization.

Overview

The program produces an ordered list of running processes selected by user-specified criteria, and updates it periodically. Default ordering is by CPU usage, and only the top CPU consumers are shown. top shows how much processing power and memory are being used, as well as other information about the running processes. Some versions of top allow extensive customization of the display, such as choice of columns or sorting method.top is useful for system administrators, as it shows which users and processes are consuming the most system resources at any given time.

Implementations

There are several different versions of top. The traditional Unix version was written by William LeFebvre and originally copyrighted in 1984.[1] It is hosted on SourceForge,[2] and release 3.7 was announced in 2008.[3]

The Linux version of top is part of the procps-ng group of tools. It was originally written by Roger Binns[4] and released in early 1992 but shortly thereafter taken over by others.[5]

On Solaris, the roughly equivalent program is prstat. Microsoft Windows has the tasklist command and the graphical Task Manager utility. IBM AIX has an updating running processes list as part of the topas and topas_nmon commands.

The load average numbers in Linux refers to the sum of the number of processes waiting in the run-queue plus the number currently executing. The number is absolute, not relative. And thus it can be unbounded; unlike utilization. The instant variations of the number of processes are damped with an exponential decay formula which is calculated using fixed point math.[6]

The ps program is similar to top, but instead produces a snapshot of processes taken at the time of invocation. top's (number of iterations) option can product a similar result, causing the program to run the specified number of iterations, then exit after printing its output.

Example

The first 5 rows overview the entire system.

top - 14:21:23 up 2 days, 21:40, 44 users, load average: 14.44, 14.13, 14.64 | | | |

Tasks: 1552 total, 8 running, 1544 sleeping, 0 stopped, 0 zombie

%Cpu(s): 9.6 us, 0.7 sy, 0.0 ni, 89.5 id, 0.0 wa, 0.0 hi, 0.2 si, 0.0 st | | | | | | | '------.

MiB Mem : 1031911.+total, 368915.2 free, 172285.0 used, 490711.5 buff/cacheMiB Swap: 2048.0 total, 2048.0 free, 0.0 used. 807110.1 avail Mem

[[Load (computing)|load average]] is the exponential moving average of the run-queue length over the past 1/5/15 minutes. The run-queue includes both processes being run and waiting to be run. At complete utilization with no task switching, the load average is equal to the number of CPUs.[7]

Tasks counts the processes their statuses.

%Cpu(s) counts the percentage of CPU usage, broken down into categories.

MiB Mem

Memory usage in units of mebibyte. The buff/cache is for memory used by buffers and cache.

MiB Swap

Swap space usage in units of mebibyte. If the system needs more memory resources and the RAM is full, inactive pages in memory are moved to the swap space. In this snapshot, there's a total of 2048 MiB of swap, all free, indicating that no swapping is occurring, which is good for performance.

avail Mem

The amount of memory available for new applications, without swapping. This considers not just the unused RAM, but also the memory that can be reclaimed from RAM caches.

The rest of the text provides a table with each row being a process, with the following columns often used out of many possible columns (the choice and ordering of columns are configurable):[8]

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 1 root 20 0 2456 1612 1500 S 0.0 0.0 0:00.07 init(Ubuntu) 4 root 20 0 2456 4 0 S 0.0 0.0 0:00.00 init 656403 user2 20 0 80.0g 3.6g 370000 S 100.0 0.4 1594:38 python32024198 longnam+ 20 0 50.5g 4.7g 609200 S 1.6 0.5 204:46.85 long-name-proc2056804 longnam+ 20 0 237.1g 31.1g 23.1g S 136.8 3.1 69:54.11 python3

External links

Notes and References

  1. Web site: Documentation. https://web.archive.org/web/20080413180808/http://www.unixtop.org/license.shtml. dead. 2008-04-13. Unix Top. 2016-05-22.
  2. Web site: About Top. https://web.archive.org/web/20040420005914/http://www.unixtop.org/faq.shtml#title1. dead. 2004-04-20. LeFebvre. William. 2014-09-16. Unix Top. 2016-05-22.
  3. Web site: Top / News. SourceForge. 2016-05-22.
  4. Web site: top(1): tasks - Linux man page. Linux Documentation. 2016-05-22.
  5. Web site: Linux Top Origins Roger's world. Binns. Roger. Roger's world. 2016-05-22.
  6. Web site: UNIX Load Average Part 2: Not Your Average Average. J. Gunther. Neil. 2010. teamquest.com. 2013-06-10. https://web.archive.org/web/20120602093128/http://www.teamquest.com/pdfs/whitepaper/ldavg2.pdf. 2012-06-02. dead.
  7. Web site: Walker . Ray . 1 December 2006 . Examining Load Average . 13 March 2012 . Linux Journal.
  8. https://gitlab.com/procps-ng/procps/-/blob/master/man/top.1?ref_type=heads top(1) - Linux man page