Linux-tool top

From Thomas-Krenn-Wiki
Jump to navigation Jump to search

This article describes the purpose of the Unix-tool top and explains important filter and command functions for the process monitoring.

Information

top is a small Unix-program that outputs a list of current ongoing processes from the system and - other than the ps tool - updates it every 3 seconds per default. Furthermore, the program shows the capacity of the CPU, the current used and available RAM as well as a lot of helpful information in the area above. This small program is particularly valuable for system administrators, as it allows them to quickly gain a precise overview of users and their processes.

Installation

The top program is contained in most Linux-distributions.

Example of output

top - 14:29:44 up  6:20,  2 users,  load average: 0.24, 0.33, 0.39
Tasks: 200 total,   1 running, 197 sleeping,   2 stopped,   0 zombie
Cpu(s):  0.2%us,  0.3%sy,  0.0%ni, 99.5%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:   3916992k total,  1615976k used,  2301016k free,   135152k buffers
Swap:  2999288k total,        0k used,  2999288k free,   680008k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND            
 1382 root      20   0  163m  67m  21m S    1  1.8  12:24.83 Xorg               
 1617 amarek    20   0  296m  57m  21m S    0  1.5   2:47.17 compiz             
 1868 amarek    20   0  764m  52m  25m S    0  1.4   1:05.92 pidgin             
 2787 amarek    20   0  217m  20m  11m S    0  0.5   0:12.35 gnome-terminal     
 4308 amarek    20   0 19224 1476 1064 R    0  0.0   0:00.27 top                
    1 root      20   0 23812 1976 1276 S    0  0.1   0:01.10 init               
    2 root      20   0     0    0    0 S    0  0.0   0:00.01 kthreadd           
    3 root      RT   0     0    0    0 S    0  0.0   0:00.00 migration/0  
[...]

Head line information

  1. Uptime:
    This line shows the period since the system is online. Behind this, the load averages of 1, 5, and 15 minutes are specified.
  2. Tasks:
    This shows the number of processes that were active at the last update. It also shows how many processes are in the running, sleeping, stopped, or undead status.
  3. CPU states:
    shows the capacity of the CPU in per cent
  4. Mem:
    statistics about the capacity of the main storage
  5. Swap:
    display of the swap-capacity

Interactive commands

key name function
u user filter processes of an user
k kill ending process (PID... + signal number (15 hours)
r renice set Nice value process (PID + Nice value)
d delay set update intervall in seconds (default: 3 seconds)
n number maximum number of displayed processes
N Number sorted by PID
P Percent sorted by CPU-capacity
M Memory sorted by RAM-capacity
q quit close top
h help display help

Manual refresh of output

By clicking on the space bar, the screen output can be renewed.

Expanded alternative for top

A tool that is similar to top, which is also user-friendly, is htop.

Advantages

  • graphical representation of CPU, RAM, and swap utilization
  • process signals can be sent using simple key combination

Installation of htop

htop can be installed via the same-named package, for example under Debian:

aptitude install htop

More information


Translator: Alina Ranzinger

Alina has been working at Thomas-Krenn.AG since 2024. After her training as multilingual business assistant, she got her job as assistant of the Product Management and is responsible for the translation of texts and for the organisation of the department.


Related articles

Compiling Linux kernel under Ubuntu or Debian
Differences between hardware RAID and Linux software RAID
Searching for files in Linux with ack-grep