Finally, there's a command you can use to display updating information about the processes running on the system. This command is called top(1), and is started like so:
% top |
This will display a full screen of information about the processes running on the system, as well as some overall information about the system. This includes load average, number of processes, the CPU status, free memory information, and details about processes including PID, user, priority, CPU and memory usage information, running time, and program name.
6:47pm up 1 day, 18:01, 1 user, load average: 0.02, 0.07, 0.02
61 processes: 59 sleeping, 2 running, 0 zombie, 0 stopped
CPU states: 2.8% user, 3.1% system, 0.0% nice, 93.9% idle
Mem: 257992K av, 249672K used, 8320K free, 51628K shrd, 78248K buff
Swap: 32764K av, 136K used, 32628K free, 82600K cached
PID USER PRI NI SIZE RSS SHARE STAT LIB %CPU %MEM TIME COMMAND
112 root 12 0 19376 18M 2468 R 0 3.7 7.5 55:53 X
4947 david 15 0 2136 2136 1748 S 0 2.3 0.8 0:00 screenshot
3398 david 7 0 20544 20M 3000 S 0 1.5 7.9 0:14 gimp
4946 root 12 0 1040 1040 836 R 0 1.5 0.4 0:00 top
121 david 4 0 796 796 644 S 0 1.1 0.3 25:37 wmSMPmon
115 david 3 0 2180 2180 1452 S 0 0.3 0.8 1:35 wmaker
4948 david 16 0 776 776 648 S 0 0.3 0.3 0:00 xwd
1 root 1 0 176 176 148 S 0 0.1 0.0 0:13 init
189 david 1 0 6256 6156 4352 S 0 0.1 2.4 3:16 licq
4734 david 0 0 1164 1164 916 S 0 0.1 0.4 0:00 rxvt
2 root 0 0 0 0 0 SW 0 0.0 0.0 0:08 kflushd
3 root 0 0 0 0 0 SW 0 0.0 0.0 0:06 kupdate
4 root 0 0 0 0 0 SW 0 0.0 0.0 0:00 kpiod
5 root 0 0 0 0 0 SW 0 0.0 0.0 0:04 kswapd
31 root 0 0 340 340 248 S 0 0.0 0.1 0:00 kerneld
51 root 0 0 48 48 32 S 0 0.0 0.0 0:00 dhcpcd
53 bin 0 0 316 316 236 S 0 0.0 0.1 0:00 rpc.portmap
57 root 0 0 588 588 488 S 0 0.0 0.2 0:01 syslogd
|
It's called top because the most CPU intensive programs will be listed at the top. An interesting note is that top will be listed first on most inactive (and some active) systems because of its CPU utilization. However, top is quite useful for determining what program is misbehaving and needs to be killed off.
But suppose you only want a list of your own processes, or the processes of some other user. The processes you want to see might not be among the most CPU intensive programs currently running. The -u option allows you to specify a username or UID and monitor only those processes owned by that UID.
% top -u alan PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 3622 alan 13 0 11012 10m 6956 S 1.0 2.1 0:03.66 gnome-terminal 3739 alan 13 0 1012 1012 804 R 0.3 0.2 0:00.06 top 3518 alan 9 0 1312 1312 1032 S 0.0 0.3 0:00.09 bash 3529 alan 9 0 984 984 848 S 0.0 0.2 0:00.00 startx 3544 alan 9 0 640 640 568 S 0.0 0.1 0:00.00 xinit 3548 alan 9 0 8324 8320 6044 S 0.0 1.6 0:00.30 gnome-session 3551 alan 9 0 7084 7084 1968 S 0.0 1.4 0:00.50 gconfd-2 3553 alan 9 0 2232 2232 380 S 0.0 0.4 0:00.05 esd 3555 alan 9 0 2552 2552 1948 S 0.0 0.5 0:00.10 bonobo-activati 3557 alan 9 0 2740 2740 2224 S 0.0 0.5 0:00.05 gnome-smproxy 3559 alan 9 0 6496 6492 5004 S 0.0 1.3 0:00.31 gnome-settings- 3565 alan 9 0 1740 1740 1440 S 0.0 0.3 0:00.28 xscreensaver 3568 alan 9 0 7052 7052 4960 S 0.0 1.4 0:02.28 metacity 3572 alan 9 0 11412 11m 7992 S 0.0 2.2 0:01.58 gnome-panel 3574 alan 9 0 12148 11m 8780 S 0.0 2.4 0:00.64 nautilus 3575 alan 9 0 12148 11m 8780 S 0.0 2.4 0:00.00 nautilus 3576 alan 9 0 12148 11m 8780 S 0.0 2.4 0:00.00 nautilus |
As you can see, I'm currently running X, top, a gnome-terminal (in which I'm writing this) and many other X-related processes which take up the most CPU time for me. This is a good way to monitor how hard your users are working your system.
top also supports monitoring processes by their PID, ignoring idle and zombied processes, and many other options. The best place to get a handle on these options is the man page for top.