Learn N Try

For all Lean Enthusiast

Top Command

[root@rhel7 ~]# top

top – 11:27:02 up 18 min,  2 users,  load average: 0.00, 0.05, 0.14

Tasks: 136 total,   2 running, 134 sleeping,   0 stopped,   0 zombie

%Cpu(s):  0.9 us,  1.0 sy,  0.0 ni, 91.9 id,  6.1 wa,  0.0 hi,  0.0 si,  0.0 st

KiB Mem :  1884188 total,  1276776 free,   268756 used,   338656 buff/cache

KiB Swap:  1572860 total,  1572860 free,        0 used.  1451444 avail Mem

 

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
1 root 20 0 126580 7364 2628 S 0 0.4 00:01.8 systemd

 

Each of the following three areas are individually controlled through one or more interactive commands.  See topic 4b. SUMMARY AREA Commands for additional       information regarding these provisions.

UPTIME and LOAD Averages

This portion consists of a single line containing:

  • program or window name, depending on display mode
  • current time and length of time since last boot
  • total number of users
  • system load avg over the last 1, 5 and 15 minutes

 

TASK and CPU States

This portion consists of a minimum of two lines.  In an SMP environment, additional lines can reflect individual CPU state percentages.

Line 1 shows total tasks or threads, depending on the state of the Threads-mode toggle. That total is further classified as:

running; sleeping; stopped; zombie

Line 2 shows CPU state percentages based on the interval since the last refresh. As a default, percentages for these individual categories are displayed.  Where two labels are shown below, those for more recent kernel versions are shown first.

us, user    : time running un-niced user processes

sy, system  : time running kernel processes

ni, nice    : time running niced user processes

id, idle    : time spent in the kernel idle handler

wa, IO-wait : time waiting for I/O completion

hi : time spent servicing hardware interrupts

si : time spent servicing software interrupts

st : time stolen from this vm by the hypervisor

 

In the alternate cpu states display modes, beyond the first tasks/threads line, an abbreviated summary is shown consisting of these elements:

a    b     c    d

%Cpu(s):  75.0/25.0  100[ …

 

Where: a) is the combined us and ni percentage; b) is the sy percentage; c) is the total; and d) is one of two visual graphs of those representations.   See

topic 4b. SUMMARY AREA Commands and the `t’ command for additional information on that special 4-way toggle.

 

MEMORY Usage

This portion consists of two lines which may express values in kibibytes (KiB) through exbibytes (EiB) depending on the scaling factor enforced with the `E’ interactive command.

As a default, Line 1 reflects physical memory, classified as:

total, free, used and buff/cache

Line 2 reflects mostly virtual memory, classified as:

total, free, used and avail (which is physical memory)

The avail number on line 2 is an estimation of physical memory available for starting new applications, without swapping. Unlike the free field, it attempts to account for readily reclaimable page cache and memory slabs. It is available on kernels 3.14, emulated on kernels 2.6.27+, otherwise the same as free.

In the alternate memory display modes, two abbreviated summary lines are shown consisting of these elements:

a    b          c

GiB Mem : 18.7/15.738   [ …

GiB Swap:  0.0/7.999    [ …

Where: a) is the percentage used; b) is the total available; and c) is one of two visual graphs of those representations.

In the case of physical memory, the percentage represents the total minus the estimated avail noted above. The `Mem’ graph itself is divided between used and any remaining memory not otherwise accounted for by avail.  See topic 4b. SUMMARY AREA Commands and the `m’ command for additional information on that special 4-way toggle.

This table may help in interpreting the scaled values displayed:

KiB = kibibyte = 1024 bytes

MiB = mebibyte = 1024 KiB = 1,048,576 bytes

GiB = gibibyte = 1024 MiB = 1,073,741,824 bytes

TiB = tebibyte = 1024 GiB = 1,099,511,627,776 bytes

PiB = pebibyte = 1024 TiB = 1,125,899,906,842,624 bytes

EiB = exbibyte = 1024 PiB = 1,152,921,504,606,846,976 bytes

 

  • Nice value in between -20 to 19
  • NI­ PR¯
  • NI¯ PR­
  • Normal user can only increase NI value but it cannot decrease it.
  • Only root user can do both

 

Example:

# dd if = /dev/zero of = /dev/null &

# renice -n -15 <PID>                // to change priority of process

# renice -n -5 -u <user>                        //all process of this will set to this priority