summaryrefslogtreecommitdiffstats
path: root/slackbook/html/process-control-top.html
blob: c15f0f4ee1cec98b24b22d26544a8d8c64ba530c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="generator" content="HTML Tidy, see www.w3.org" />
<title>top</title>
<meta name="GENERATOR" content="Modular DocBook HTML Stylesheet Version 1.7" />
<link rel="HOME" title="Slackware Linux Essentials" href="index.html" />
<link rel="UP" title="Process Control" href="process-control.html" />
<link rel="PREVIOUS" title="kill" href="process-control-kill.html" />
<link rel="NEXT" title="Essential System Administration"
href="essential-sysadmin.html" />
<link rel="STYLESHEET" type="text/css" href="docbook.css" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body class="SECT1" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#840084"
alink="#0000FF">
<div class="NAVHEADER">
<table summary="Header navigation table" width="100%" border="0" cellpadding="0"
cellspacing="0">
<tr>
<th colspan="3" align="center">Slackware Linux Essentials</th>
</tr>

<tr>
<td width="10%" align="left" valign="bottom"><a href="process-control-kill.html"
accesskey="P">Prev</a></td>
<td width="80%" align="center" valign="bottom">Chapter 11 Process Control</td>
<td width="10%" align="right" valign="bottom"><a href="essential-sysadmin.html"
accesskey="N">Next</a></td>
</tr>
</table>

<hr align="LEFT" width="100%" />
</div>

<div class="SECT1">
<h1 class="SECT1"><a id="PROCESS-CONTROL-TOP" name="PROCESS-CONTROL-TOP">11.5 <tt
class="COMMAND">top</tt></a></h1>

<p>Finally, there's a command you can use to display updating information about the
processes running on the system. This command is called <tt class="COMMAND">top</tt>(1),
and is started like so:</p>

<table border="0" bgcolor="#E0E0E0" width="100%">
<tr>
<td>
<pre class="SCREEN">
<samp class="PROMPT">%</samp> <kbd class="USERINPUT">top</kbd>
</pre>
</td>
</tr>
</table>

<p>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.</p>

<table border="0" bgcolor="#E0E0E0" width="100%">
<tr>
<td>
<pre class="SCREEN">
 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

<span class="emphasis"><i
class="EMPHASIS">PID USER    PRI  NI  SIZE  RSS  SHARE  STAT  LIB %CPU %MEM  TIME COMMAND</i></span>
 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
</pre>
</td>
</tr>
</table>

<p>It's called <tt class="COMMAND">top</tt> 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, <tt
class="COMMAND">top</tt> is quite useful for determining what program is misbehaving and
needs to be killed off.</p>

<p>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 <var class="OPTION">-u</var> option allows you to specify a
username or UID and monitor only those processes owned by that UID.</p>

<table border="0" bgcolor="#E0E0E0" width="100%">
<tr>
<td>
<pre class="SCREEN">
<samp class="PROMPT">%</samp> <kbd class="USERINPUT">top -u alan</kbd>
 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
</pre>
</td>
</tr>
</table>

<p>As you can see, I'm currently running <tt class="COMMAND">X</tt>, <tt
class="COMMAND">top</tt>, a <tt class="COMMAND">gnome-terminal</tt> (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.</p>

<p><tt class="COMMAND">top</tt> 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 <tt class="COMMAND">top</tt>.</p>
</div>

<div class="NAVFOOTER">
<hr align="LEFT" width="100%" />
<table summary="Footer navigation table" width="100%" border="0" cellpadding="0"
cellspacing="0">
<tr>
<td width="33%" align="left" valign="top"><a href="process-control-kill.html"
accesskey="P">Prev</a></td>
<td width="34%" align="center" valign="top"><a href="index.html"
accesskey="H">Home</a></td>
<td width="33%" align="right" valign="top"><a href="essential-sysadmin.html"
accesskey="N">Next</a></td>
</tr>

<tr>
<td width="33%" align="left" valign="top"><tt class="COMMAND">kill</tt></td>
<td width="34%" align="center" valign="top"><a href="process-control.html"
accesskey="U">Up</a></td>
<td width="33%" align="right" valign="top">Essential System Administration</td>
</tr>
</table>
</div>
</body>
</html>