Linux Top

Sort by memory usage:

top -bn1M

Sort by CPU usage:

top -bn1P

Display only selected PIDs:

top -c -p 1234,5678

CPU States: Time spent in niced tasks will also be counted in system and user time, so the total will be more than 100%.

18:46:13  up 11 days, 21:50,  5 users,  load average: 0.11, 0.19, 0.18

shows the current time (18:46:13), that system has been up for 11 days; that the system has been working for 21 hours 50 seconds. The load average of the system is shown (0.11, 0.19, 0.18) for the last 1, 5 and 15 minutes respectively.

The CPU line show %user, %system, %nice, %idle, %iowait, %hi, %si, %st

If there are more than one CPU, you will see one line for each CPU.

SIZE: Memory used by this process (code+data+stack)

VIRT: Virtual Size of the task. This includes the size of process's executable binary, the data area and all the loaded shared libraries.

RES: The size of RAM currently consumed by the task. Swapped out portion of the task is not included.

SHR: Some memory areas could be shared between two or more task, this field reflects that shared areas. The example of shared area are shared library and SysV shared memory.

RSS: The physical memory used by this process

SHARE: The shared memory used by this process

%CPU: The percentage of CPU used by this process

%MEM: The percentage of memory used by this process

TIME: The total CPU time used by this process

CPU: If this is a multi-processor system, this column indicates the ID of the CPU this process is running on.

Pressing the uppercase M key sorts the output by memory usage.

To monitor only specified process:

top -p 13609 -p 13608 -p 13554

P: sort tasks by CPU usage (default).
M: sort tasks by resident memory usage.

After pressing f, F, o or O you will be shown a screen specifying the field order on the top line and short descriptions of the field contents. The field order string uses the following syntax: If the letter in the filed string corresponding to a field is upper case, the field will be displayed. This is furthermore indicated by an asterisk in front of the field description. The order of the fields corresponds to the order of the letters in the string. From the field select screen you can toggle the display of a field by pressing the corresponding letter.
From the order screen you may move a field to the left by pressing the corresponding upper case letter resp. to the right by pressing the lower case one.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License