top - Interactive view of system resources and processes#
The top
program is one of few interactive system inspection commands. It shows real time data about running processes, memory consumption and a basic summary about the system. It really useful to inspect what is currently going on a system ans provides a starter investigate resource consumption. It a interactive program, so after invocation it will show a lot of data which is updated every 3 seconds and meanwhile it waits for further user input.
There are a lot of short cuts to control a running top, most often a single key stroke is enough to trigger an action. Most importantly hitting q
quits the top program.
A simple invocation of top
shows a header with basic system information and below a table of running processes.
Below is a typical header as displayed by top
. Breaking it down line by line already reveals a lot of information.
top - 12:34:56 up 34 days, 2:51, 1 user, load average: 60.96, 60.96, 60.80
the current system time is
12:34:56
the systems is running (uptime) for 34 days and 2h 50m.
1 user is currently logged in
the load average is
60.96 over the last minute
60.96 over the last 5 minutes
60.80 over the last 15 minutes
Tasks: 1409 total, 61 running, 1347 sleeping, 1 stopped, 0 zombie
There are 1409 processes of which
61 are running, i.e. are executed right now
1347 are inactive, usually waiting for data or disk I/O, etc.
1 is stopped, usually by a user
There are no zombie processes, which is good
%Cpu(s): 0.0 us, 20.6 sy, 26.2 ni, 52.9 id, 0.0 wa, 0.0 hi, 0.2 si, 0.0 st
This a break down of how many time (in percent) the CPUs are occupied which different tasks
us
: userland processes (with default nice value)sy
: system processesni
: userland processes (with non-default nice value)id
: idle, i.e. non of the above, \(100 - (\text{us} + \text{sy} + \text{ni})\)
The next values are for system administrators indicating time spent on handling interrupts (
hi
,si
) and waiting for I/O (wa
,st
)
top - 12:34:56 up 34 days, 2:50, 1 user, load average: 60.96, 60.96, 60.80
Tasks: 1409 total, 61 running, 1347 sleeping, 1 stopped, 0 zombie
%Cpu(s): 0.0 us, 20.6 sy, 26.2 ni, 52.9 id, 0.0 wa, 0.0 hi, 0.2 si, 0.0 st
MiB Mem : 2052001.+total, 1514273.+free, 233328.6 used, 304399.2 buff/cache
MiB Swap: 210215.0 total, 210206.5 free, 8.5 used. 1808182.+avail Mem
There is a more sophisticated version of top
called htop
the functionality is similar but the user interface is a bit simpler. Also nvtop
is similar but for GPUs.