Breadcrumbs 
Learning >> Documentation >> System Activity >> Show usage with top
 
Recent News
We're No 1!
We've reached the top! (Of Google!)
[ more ]
Firefox 3 Download Day
Firefox 3 has been officially released and is looking to set a world record for the most downloaded piece of software in 24hrs.
[ more ]
SSL Renewed
SSL cert has been renewed by the admin team.
[ more ]
Show usage with top
Show usage with top

Top is one of the most useful applications when it comes to viewing what processes are currently running in the system and what resources they are consuming.

For now we'll start top and you should see somewhat similar output to that below. There are going to be differences since this is a real time display of what is current being executed on the machine that you use this application on:

$ top
 18:11:06  up 28 min,  3 users,  load average: 0.04, 0.11, 0.08
78 processes: 74 sleeping, 3 running, 1 zombie, 0 stopped
CPU states:   7.1% user   2.1% system   0.0% nice   0.0% iowait  90.6% idle
Mem:   513848k av,  268852k used,  244996k free,       0k shrd,   17548k buff
                    232304k actv,     576k in_d,    5708k in_c
Swap: 1044216k av,       0k used, 1044216k free                  112276k cached
                                                                      
  PID USER     PRI  NI  SIZE  RSS SHARE STAT %CPU %MEM   TIME CPU COMMAND
 3890 root      15   0  286M  29M  4940 S     5.3  5.9   0:21   0 X
 4068 dara      15   0 10660  10M  7160 S     2.9  2.0   0:02   0 gnome-terminal
 3998 dara      15   0  7176 7176  5052 S     0.5  1.3   0:01   0 metacity
 4002 dara      15   0 12872  12M  8460 S     0.5  2.5   0:01   0 gnome-panel
    1 root      15   0   476  476   420 S     0.0  0.0   0:04   0 init
    2 root      15   0     0    0     0 SW    0.0  0.0   0:00   0 keventd
    3 root      15   0     0    0     0 SW    0.0  0.0   0:00   0 kapmd
    4 root      34  19     0    0     0 SWN   0.0  0.0   0:00   0 ksoftirqd_CPU0
    9 root      25   0     0    0     0 SW    0.0  0.0   0:00   0 bdflush

The first paragraph contains some general information, so first step is to explain everything that is being looked at.

  • First line shows the following:
    Current time is 18:11:06; Time that the machine has been running is 28 min, up 28 min; Number of users on machine is 3, 3 users; Load average of machine, how heavily it has been loaded for the last 1, 5 & 15 minutes, 0.03, 0.11, 0.08
  • Second line displays:
    Total number of processes running is 78, or which 74 are sleeping, 3 are currently running, 1 is in a zombie state which means that even though it is finished it hasn't terminated, and currently none are stopped.
  • Third line reads:
    7.1% of the CPU time is taken up with user processes, 2.1% of the time with system processes, no time is due to processes given a higher priority with the nice command, none have been waiting on I/O from the system and 90.6% of the time the machine has been idle.
  • Fourth line:
    Information about the memory of this machine, total is 512MB (513848KB converted to MB), about 260MB are in use and the rest is pretty much free. None is shared and about 17MB is being used for buffers. The line below also contains some additional info but its not really important.
  • Sixth line:
    Contains details about the swap memory on the machine, this basically is about the amount of designated swap space that is currently in use and is similar to the pagefile on windows (when the system memory reaches it's maximum capacity, processes are usually swapped to and from the hard drive to free up memory).

Finally we move on to what is being displayed.

  • PID = process id, this is the unique identification for every process on the machine and can be used to sent specific commands to processes running.
  • USER = username of the owner of the process.
  • PRI = current priority of this process, default is 15, 1 is the highest and processes can only be given a higher priority by root. Anything number greater than 15 indicates that the process has been given a lower priorty using the nice command.
  • NI = nice value, if you see the 8th process down you'll see that it has a NI value of 19, that means it has been assigned a lower priorty by using the nice command so that it is only run as often as required.
  • We're skipping the next four items, SIZE, RSS, SHARE & STAT, if you want to find out what these reprasent check the man page on top.
  • %CPU = the tasks share of time in the CPU, if this is high for any process it can indicate a problem or excessive use of the CPU by a process.
  • %MEM = tasks share of physical memory (RAM).
  • TIME = the total amount of time the process has spent being executed by the CPU since it was started.
  • Skipping CPU, again check the man pages to find out what this is about.
  • COMMAND = this is the process that is being executed, if it is too long it will be truncated to fit.

There's plenty more about top but its suggested that you read the man page or look online for more information. Just the essentials and the main features of it are being explained here so that it helps you make use of the application. Next we'll cover some of the basic commands that can be used when operating top, again the man page or the help section in this program will contain a more comprehensive list of what can be done. To access help while running top press the 'h' key.

For starters lets update top by pressing space, you'll see that this updates the view straight away, if you don't it will be automatically updated once every 5 seconds. Next we're going to change the view so that it only displays what processes you are currently running. Press the following key:

u

 22:02:45  up  4:19,  4 users,  load average: 0.26, 0.47, 0.81
79 processes: 74 sleeping, 4 running, 1 zombie, 0 stopped
CPU states:  10.6% user   0.4% system   0.0% nice   0.0% iowait  89.0% idle
Mem:   513848k av,  467840k used,   46008k free,       0k shrd,   18792k buff
                    345584k actv,     192k in_d,    8876k in_c
Swap: 1044216k av,   43668k used, 1000548k free                  295868k cached
Which User (Blank for All):
  PID USER     PRI  NI  SIZE  RSS SHARE STAT %CPU %MEM   TIME CPU COMMAND


You'll see the top of the screen change to above, type in your username and press enter:

dara
 22:05:12  up  4:22,  4 users,  load average: 1.17, 0.65, 0.81
79 processes: 76 sleeping, 2 running, 1 zombie, 0 stopped
CPU states:   9.7% user   1.6% system   0.0% nice   0.0% iowait  88.5% idle
Mem:   513848k av,  468064k used,   45784k free,       0k shrd,   19052k buff
                    345876k actv,     184k in_d,    8876k in_c
Swap: 1044216k av,   43668k used, 1000548k free                  295892k cached

  PID USER     PRI  NI  SIZE  RSS SHARE STAT %CPU %MEM   TIME CPU COMMAND
 4049 dara      15   0 41336  39M 17080 S     2.6  7.9   3:38   0 galeon-bin
 4068 dara      15   0  7468 7464  3008 R     1.1  1.4   0:17   0 gnome-terminal
 3998 dara      15   0  4632 4468  2416 S     0.1  0.8   0:38   0 metacity
 4002 dara      15   0  8668 8664  3684 S     0.1  1.6   0:13   0 gnome-panel
 4106 dara      15   0  2260 2260  1088 S     0.1  0.4   0:03   0 vim
 5047 dara      15   0  7132 7128  4860 S     0.1  1.3   0:05   0 gnome-cd
 3923 dara      15   0  3708  900   412 S     0.0  0.1   0:00   0 gnome-session
 3972 dara      15   0   348  252   144 S     0.0  0.0   0:00   0 ssh-agent

As you should now see only the processes belonging to you are displayed. In this case you can see that the user shown here is currently running galeon (web browser), gnome-terminal (command line terminal run from a gnome desktop), metacity (controls the window manager), gnome-panel (like the taskbar in windows only this is for gnome desktops), vim (text editor being used to write this), gnome-cd (plays audio cd while this is being typed). The list goes on but its been cut down to make it easier to view.

You can press 'u' followed by enter to return to the view of all processes belonging to everyone, just remember that the list will be so long that most will not be displayed since they won't fit into the terminal screen. Just the most recent in the CPU are displayed. When your ready to exit just press 'q' and you'll be returned to the command line.

q
$

Should you want to learn more just use:

$ man top

Which will give you a list of addition commands that can be used within this application.