Monday, August 3, 2009

Top Command in Detail

top is a system administration tool which allows the root user to view processes running on the system and other vital system information.

Enter top -S to display resource use information using "cumulative" mode (the -S flag will report CPU time used by processes and their children since top -S was started).

top - 03:31:05 up 7:40, 1 user, load average: 0.00, 0.00, 0.00
Tasks: 15 total, 1 running, 14 sleeping, 0 stopped, 0 zombie
Cpu(s): 0.1% us, 0.0% sy, 0.0% ni, 99.9% id, 0.0% wa, 0.0% hi, 0.0% si
Mem: 512000k total, 115552k used, 396448k free, 0k buffers
Swap: 0k total, 0k used, 0k free, 0k cached

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
1 root 15 0 1516 520 452 S 0.0 0.1 0:05.28 init
1559 root 15 0 1564 536 440 S 0.0 0.1 0:00.03 syslogd
1579 root 18 0 2512 1228 1016 S 0.0 0.2 0:00.01 mysqld_safe
1598 root 18 0 2512 560 344 S 0.0 0.1 0:00.00 mysqld_safe
1599 mysql 18 0 97960 16m 3100 S 0.0 3.2 0:02.06 mysqld
1600 root 21 0 1496 504 440 S 0.0 0.1 0:00.00 logger
1673 daemon 18 0 1696 368 280 S 0.0 0.1 0:00.00 atd
1676 root 15 0 1776 748 604 S 0.0 0.1 0:02.16 cron
1683 root 18 0 10516 4216 3184 S 0.0 0.8 0:00.21 apache
1696 www-data 15 0 10520 1988 896 S 0.0 0.4 0:00.00 apache
1697 www-data 15 0 10520 1960 868 S 0.0 0.4 0:00.00 apache
11830 root 18 0 3472 896 660 S 0.0 0.2 0:03.91 sshd
28133 root 15 0 14456 1980 1456 S 0.0 0.4 0:00.19 sshd
28166 root 15 0 2568 1408 1128 S 0.0 0.3 0:00.68 bash
21716 root 15 0 2072 1028 836 R 0.0 0.2 0:00.04 top


Column Names

Commonly-used columns:

1. PID - Process ID - The unique ID of the process (commonly used with the kill command)
2. USER - Username which the process is running under
3. PR - Priority for the process (ranges from -20 for very important processes to 19 for unimportant processes)
4. NI - Nice value modifies the priority of the process (a negative value will increase the priority of the process and a positive value will decrease the priority of the process)
5. VIRT - Total amount of virtual memory used by the process
6. RES - Resident size (kb) - Non-swapped physical memory which the process has used
7. SHR - Shared memory size (kb) - Amount of shared memory which the process has used (shared memory is memory which could be allocated to other processes)
8. S - Process status - Possible values:
* R - Running
* D - Sleeping (may not be interrupted)
* S - Sleeping (may be interrupted)
* T - Traced or stopped
* Z - Zombie or "hung" process
9. %CPU - Percentage of CPU time the process was using at the time top last updated
10. %MEM - Percentage of memory (RAM) the process was using at the time top last updated
11. TIME+ - Cumulative CPU time which the process and children of the process have used
12. COMMAND - Name of the process or the path to the command used to start the process (press c to toggle between the name of the process and the path to the command used to start the process)

No comments:

Post a Comment