Thursday, 28th August 2008
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:
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.
Finally we move on to what is being displayed.
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
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
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.