TOP command in Linux

top provides an ongoing look at processor activity in real time. It displays a listing of the most CPU-intensive tasks on the system, and can provide an interactive interface for manipulating processes. It can sort the tasks by CPU usage, memory usage and runtime. can be better configured than the standard top from the procps suite. Most features can either be selected by an interactive command or by specifying the feature in the personal or system-wide configuration file.

Understanding TOP command

1° Row — top

top command 1 row

This first line indicates in order:

  • current time (11:37:19)
  • uptime of the machine (up 1 day, 1:25)
  • users sessions logged in (3 users)
  • average load on the system (load average: 0.02, 0.12, 0.07) the 3 values refer to the last minute, five minutes and 15 minutes.

2° Row – task

top command 2 row

The second row gives the following information:

  • Processes running in totals (73 total)
  • Processes running (2 running)
  • Processes sleeping (71 sleeping)
  • Processes stopped (0 stopped)
  • Processes waiting to be stoppati from the parent process (0 zombie)

3° Row – cpu

top command 3 row

The third line indicates how the cpu is used. If you sum up all the percentages the total will be 100% of the cpu. Let’s see what these values indicate in order:

  • Percentage of the CPU for user processes (0.3%us)
  • Percentage of the CPU for system processes (0.0%sy)
  • Percentage of the CPU processes with priority upgrade nice (0.0%ni)
  • Percentage of the CPU not used (99,4%id)
  • Percentage of the CPU processes waiting for I/O operations(0.0%wa)
  • Percentage of the CPU serving hardware interrupts (0.3% hi — Hardware IRQ
  • Percentage of the CPU serving software interrupts (0.0% si — Software Interrupts
  • The amount of CPU ‘stolen’ from this virtual machine by the hypervisor for other tasks (such as running another virtual machine) this will be 0 on desktop and server without Virtual machine. (0.0%st — Steal Time)

4° and 5° Rows – memory usage

top command 4-5 row

The fourth and fifth rows respectively indicate the use of physical memory (RAM) and swap. In this order: Total memory in use, free, buffers cached. On this topic you can also read the following article

Following Rows — Processes list

top command last row

And as last thing ordered by CPU usage (as default) there are the processes currently in use. Let’s see what information we can get in the different columns:

  • PID – l’ID of the process(4522)
  • USER – The user that is the owner of the process (root)
  • PR – priority of the process (15)
  • NI – The “NICE” value of the process (0)
  • VIRT – virtual memory used by the process (132m)
  • RES – physical memory used from the process (14m)
  • SHR – shared memory of the process (3204)
  • S – indicates the status of the process: S=sleep R=running Z=zombie (S)
  • %CPU – This is the percentage of CPU used by this process (0.3)
  • %MEM – This is the percentage of RAM used by the process (0.7)
  • TIME+ –This is the total time of activity of this process (0:17.75)
  • COMMAND – And this is the name of the process (


Now that we have seen in detail all the information that the command “top” returns, it will be easier to understand the reason of excessive load and/or the slowing of the system.

TOP Command Options


Specifies the delay between screen updates. You can change this with the S interactive command.


Monitor only processes with given process id. This flag can be given up to twenty times. This option is neither available interactively nor can it be put into the configuration file.


This causes top to refresh without any delay. If the caller has superuser privileges, top runs with the highest possible priority.


Specifies cumulative mode, where each process is listed with the CPU time that it as well as its dead children has spent. This is like the -S flag to ps(1). See the discussion below of the S interactive command.-sTells top to run in secure mode. This disables the potentially dangerous of the interactive commands (see below). A secure top is a nifty thing to leave running on a spare terminal.


Start top ignoring any idle or zombie processes. See the interactive command i below.


display total CPU states instead of individual CPUs. This option only affects SMP systems.-cdisplay command line instead of the command name only. The default behavior has been changed as this seems to be more useful.


Show all threads.


Number of iterations. Update the display this number of times and then exit.


Batch mode. Useful for sending output from top to other programs or to a file. In this mode, top will not accept command line input. It runs until it produces the number of iterations requested with the n option or until killed. Output is plain text suitable for display on a dumb terminal.


top displays a variety of information about the processor state. The display is updated every 5 seconds by default, but you can change that with the d command-line option or the sinteractive command.“uptime”This line displays the time the system has been up, and the three load averages for the system. The load averages are the average number of process ready to run during the last 1, 5 and 15 minutes. This line is just like the output of uptime(1). The uptime display may be toggled by the interactive l command.processesThe total number of processes running at the time of the last update. This is also broken down into the number of tasks which are running, sleeping, stopped, or undead. The processes and states display may be toggled by the t interactive command.“CPU states”Shows the percentage of CPU time in user mode, system mode, niced tasks, iowait and idle. (Niced tasks are only those whose nice value is positive.) Time spent in niced tasks will also be counted in system and user time, so the total will be more than 100%. The processes and states display may be toggled by the t interactive command.MemStatistics on memory usage, including total available memory, free memory, used memory, shared memory, and memory used for buffers. The display of memory information may be toggled by the m interactive command.SwapStatistics on swap space, including total swap space, available swap space, and used swap space. This and Mem are just like the output of free(1).PIDThe process ID of each task.PPIDThe parent process ID each task.UIDThe user ID of the task’s owner.USERThe user name of the task’s owner.PRIThe priority of the task.NIThe nice value of the task. Negative nice values are higher priority.SIZEThe size of the task’s code plus data plus stack space, in kilobytes, is shown here.TSIZEThe code size of the task. This gives strange values for kernel processes and is broken for ELF processes.DSIZEData + Stack size. This is broken for ELF processes.TRSText resident size.SWAPSize of the swapped out part of the task.DSize of pages marked dirty.LCLast used processor. (That this changes from time to time is not a bug; Linux intentionally uses weak affinity. Also notice that the very act of running top may break weak affinity and cause more processes to change current CPU more often because of the extra demand for CPU time.)RSSThe total amount of physical memory used by the task, in kilobytes, is shown here. For ELF processes used library pages are counted here, for a.out processes not.SHAREThe amount of shared memory used by the task is shown in this column.STATThe state of the task is shown here. The state is either S for sleeping, D for uninterruptible sleep, R for running, Z for zombies, or T for stopped or traced. These states are modified by trailing < for a process with negative nice value, N for a process with positive nice value, W for a swapped out process (this does not work correctly for kernel processes).WCHANdepending on the availability of either /boot/psdatabase or the kernel link map/boot/ this shows the address or the name of the kernel function the task currently is sleeping in.TIMETotal CPU time the task has used since it started. If cumulative mode is on, this also includes the CPU time used by the process’s children which have died. You can set cumulative mode with the S command line option or toggle it with the interactive command S. The header line will then be changed to CTIME.%CPUThe task’s share of the CPU time since the last screen update, expressed as a percentage of total CPU time per processor.%MEMThe task’s share of the physical memory.COMMANDThe task’s command name, which will be truncated if it is too long to be displayed on one line. Tasks in memory will have a full command line, but swapped-out tasks will only have the name of the program in parentheses (for example, “(getty)”).“A , WP”these fields from the kmem top are not supported.


Several single-key commands are recognized while top is running. Some are disabled if the soption has been given on the command line.spaceImmediately updates the display.^LErases and redraws the screen.h or ?Displays a help screen giving a brief summary of commands, and the status of secure and cumulative modes.kKill a process. You will be prompted for the PID of the task, and the signal to send to it. For a normal kill, send signal 15. For a sure, but rather abrupt, kill, send signal 9. The default signal, as with kill(1), is 15, SIGTERM. This command is not available in secure mode.iIgnore idle and zombie processes. This is a toggle switch.IToggle between Solaris (CPU percentage divided by total number of CPUs) and Irix (CPU percentage calculated solely by amount of time) views. This is a toggle switch that affects only SMP systems.n or #Change the number of processes to show. You will be prompted to enter the number. This overrides automatic determination of the number of processes to show, which is based on window size measurement. If 0 is specified, then top will show as many processes as will fit on the screen; this is the default.qQuit.rRe-nice a process. You will be prompted for the PID of the task, and the value to nice it to. Entering a positve value will cause a process to be niced to negative values, and lose priority. If root is running top, a negative value can be entered, causing a process to get a higher than normal priority. The default renice value is 10. This command is not available in secure mode.SThis toggles cumulative mode, the equivalent of ps -S, i.e., that CPU times will include a process’s defunct children. For some programs, such as compilers, which work by forking into many separate tasks, normal mode will make them appear less demanding than they actually are. For others, however, such as shells and init, this behavior is correct. In any case, try cumulative mode for an alternative view of CPU use.sChange the delay between updates. You will be prompted to enter the delay time, in seconds, between updates. Fractional values are recognized down to microseconds. Entering 0 causes continuous updates. The default value is 5 seconds. Note that low values cause nearly unreadably fast displays, and greatly raise the load. This command is not available in secure mode.f or FAdd fields to display or remove fields from the display. See below for more information.o or OChange order of displayed fields. See below for more information.ltoggle display of load average and uptime information.mtoggle display of memory information.ttoggle display of processes and CPU states information.ctoggle display of command name or full command line.Nsort tasks by pid (numerically).Asort tasks by age (newest first).Psort tasks by CPU usage (default).Msort tasks by resident memory usage.Tsort tasks by time / cumulative time.WWrite current setup to ~/.toprc. This is the recommended way to write a top configuration file.

0 thoughts on “TOP command in Linux

Leave a Reply