Categories
commands system monitoring

The Top command

top command for system monitoring.
TOP is one of the system load monitoring command.Others are ps ,iostat and vmstat.
using top command you can kill the process causing high load on the system.

$top

enter top and you will see the following screen

top - 05:44:25 up  6:32,  2 users,  load average: 0.06, 0.18, 0.15
Tasks:  90 total,   1 running,  89 sleeping,   0 stopped,   0 zombie
Cpu(s):  0.8%us,  0.0%sy,  0.0%ni, 99.0%id,  0.0%wa,  0.2%hi,  0.0%si,  0.0%st
Mem:    484188k total,   476212k used,     7976k free,    63728k buffers
Swap:   489940k total,      104k used,   489836k free,   214956k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND           
 3663 nandam    15   0 36852  15m 9.8m S    1  3.2   0:00.32 gnome-terminal    
 2493 root      15   0 63456  22m 8716 S    0  4.7   5:55.30 Xorg              
 2668 nandam    15   0 15328 2272 1436 S    0  0.5   0:11.07 gnome-screensav   
    1 root      15   0  2036  720  620 S    0  0.1   0:01.28 init              
    2 root      RT   0     0    0    0 S    0  0.0   0:00.00 migration/0       
    3 root      34  19     0    0    0 S    0  0.0   0:04.44 ksoftirqd/0       
    4 root      RT   0     0    0    0 S    0  0.0   0:00.00 migration/1       
    5 root      34  19     0    0    0 S    0  0.0   0:00.48 ksoftirqd/1       
    6 root      10  -5     0    0    0 S    0  0.0   0:00.12 events/0          
    7 root      10  -5     0    0    0 S    0  0.0   0:00.00 events/1          
    8 root      10  -5     0    0    0 S    0  0.0   0:00.00 khelper           
    9 root      10  -5     0    0    0 S    0  0.0   0:00.00 kthread           
   13 root      12  -5     0    0    0 S    0  0.0   0:00.00 kblockd/0         
   14 root      10  -5     0    0    0 S    0  0.0   0:00.00 kblockd/1         
   15 root      15  -5     0    0    0 S    0  0.0   0:00.00 kacpid            
   92 root      10  -5     0    0    0 S    0  0.0   0:00.00 kseriod           
  134 root      15   0     0    0    0 S    0  0.0   0:00.19 pdflush  
         

You can see the process are listed in descending order of CPU usage. Top always displays a dyanamic list of processes. In the top portion of the report it displays the total uptime of the system, no of users , no of processes running and the total CPU,memory  adn swap space usage of the system.

You can sort the output in the descending order of memory usage by hitting M. to return to intial report hit M again.
if dont want the idle processes to be displayed hit i. To return to initial output press i again.

If you want to see the process of  single user, press u and enter the user name and to revert back press u again and donot enter any username.

You can kill the process by pressing K and enter the process id .

For More info refer top manual

to exit from TOP command press ‘q’ or ctrl+c.