]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - bin/ps/ps.1
Reimplemented bsd.nls.mk using bsd.files.mk and bsd.links.mk.
[FreeBSD/FreeBSD.git] / bin / ps / ps.1
1 .\" Copyright (c) 1980, 1990, 1991, 1993, 1994
2 .\"     The Regents of the University of California.  All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
6 .\" are met:
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\"    notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\"    notice, this list of conditions and the following disclaimer in the
11 .\"    documentation and/or other materials provided with the distribution.
12 .\" 3. All advertising materials mentioning features or use of this software
13 .\"    must display the following acknowledgement:
14 .\"     This product includes software developed by the University of
15 .\"     California, Berkeley and its contributors.
16 .\" 4. Neither the name of the University nor the names of its contributors
17 .\"    may be used to endorse or promote products derived from this software
18 .\"    without specific prior written permission.
19 .\"
20 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 .\" SUCH DAMAGE.
31 .\"
32 .\"     @(#)ps.1        8.3 (Berkeley) 4/18/94
33 .\" $FreeBSD$
34 .\"
35 .Dd April 18, 1994
36 .Dt PS 1
37 .Os
38 .Sh NAME
39 .Nm ps
40 .Nd process status
41 .Sh SYNOPSIS
42 .Nm
43 .Op Fl aCcefhjlmrSTuvwxZ
44 .Op Fl M Ar core
45 .Op Fl N Ar system
46 .Op Fl O Ar fmt
47 .Op Fl o Ar fmt
48 .Op Fl p Ar pid
49 .Op Fl t Ar tty
50 .Oo Fl U Ar username Ns Xo
51 .Op , Ns Ar username Ns No ...
52 .Xc
53 .Oc
54 .Nm
55 .Op Fl L
56 .Sh DESCRIPTION
57 The
58 .Nm
59 utility
60 displays a header line followed by lines containing information about your
61 processes that have controlling terminals.
62 This information is sorted by controlling terminal, then by process
63 .Tn ID .
64 .Pp
65 The information displayed is selected based on a set of keywords (see the
66 .Fl L
67 .Fl O
68 and
69 .Fl o
70 options).
71 The default output format includes, for each process, the process'
72 .Tn ID ,
73 controlling terminal, cpu time (including both user and system time),
74 state, and associated command.
75 .Pp
76 The process filesystem (see
77 .Xr procfs 5 )
78 should be mounted when
79 .Nm
80 is executed, otherwise not all information will be available.
81 .Pp
82 The options are as follows:
83 .Bl -tag -width indent
84 .It Fl a
85 Display information about other users' processes as well as your own.
86 This can be disabled by setting the
87 .Va security.bsd.see_other_uids
88 sysctl to zero.
89 .It Fl c
90 Change the ``command'' column output to just contain the executable name,
91 rather than the full command line.
92 .It Fl C
93 Change the way the cpu percentage is calculated by using a ``raw''
94 cpu calculation that ignores ``resident'' time (this normally has
95 no effect).
96 .It Fl e
97 Display the environment as well.
98 .It Fl f
99 Show commandline and environment information about swapped out processes.
100 This option is honored only if the uid of the user is 0.
101 .It Fl h
102 Repeat the information header as often as necessary to guarantee one
103 header per page of information.
104 .It Fl j
105 Print information associated with the following keywords:
106 user, pid, ppid, pgid, jobc, state, tt, time and command.
107 .It Fl L
108 List the set of available keywords.
109 .It Fl l
110 Display information associated with the following keywords:
111 uid, pid, ppid, cpu, pri, nice, vsz, rss, mwchan, state, tt, time
112 and command.
113 .It Fl M
114 Extract values associated with the name list from the specified core
115 instead of the default
116 .Pa /dev/kmem .
117 .It Fl m
118 Sort by memory usage, instead of by process
119 .Tn ID .
120 .It Fl N
121 Extract the name list from the specified system instead of the default
122 .Pa /boot/kernel/kernel .
123 .It Fl O
124 Add the information associated with the space or comma separated list
125 of keywords specified, after the process
126 .Tn ID ,
127 in the default information
128 display.
129 Keywords may be appended with an equals (``='') sign and a string.
130 This causes the printed header to use the specified string instead of
131 the standard header.
132 .It Fl o
133 Display information associated with the space or comma separated
134 list of keywords specified.
135 Multiple keywords may also be given in the form of more than one
136 .Fl o
137 option.
138 Keywords may be appended with an equals (``='') sign and a string.
139 This causes the printed header to use the specified string instead of
140 the standard header.
141 .It Fl p
142 Display information associated with the specified process
143 .Tn ID .
144 .It Fl r
145 Sort by current cpu usage, instead of by process
146 .Tn ID .
147 .It Fl S
148 Change the way the process time is calculated by summing all exited
149 children to their parent process.
150 .It Fl T
151 Display information about processes attached to the device associated
152 with the standard input.
153 .It Fl t
154 Display information about processes attached to the specified terminal
155 device.
156 .It Fl U
157 Display the processes belonging to the specified
158 .Ar username Ns (s) .
159 .It Fl u
160 Display information associated with the following keywords:
161 user, pid, %cpu, %mem, vsz, rss, tt, state, start, time and command.
162 The
163 .Fl u
164 option implies the
165 .Fl r
166 option.
167 .It Fl v
168 Display information associated with the following keywords:
169 pid, state, time, sl, re, pagein, vsz, rss, lim, tsiz,
170 %cpu, %mem and command.
171 The
172 .Fl v
173 option implies the
174 .Fl m
175 option.
176 .It Fl w
177 Use 132 columns to display information, instead of the default which
178 is your window size.
179 If the
180 .Fl w
181 option is specified more than once,
182 .Nm
183 will use as many columns as necessary without regard for your window size.
184 .It Fl x
185 Display information about processes without controlling terminals.
186 .It Fl Z
187 Add lvl to the list of keywords for which
188 .Nm
189 will display information.
190 .El
191 .Pp
192 A complete list of the available keywords are listed below.
193 Some of these keywords are further specified as follows:
194 .Bl -tag -width mtxname
195 .It %cpu
196 The cpu utilization of the process; this is a decaying average over up to
197 a minute of previous (real) time.
198 Since the time base over which this is computed varies (since processes may
199 be very young) it is possible for the sum of all
200 .Tn \&%CPU
201 fields to exceed 100%.
202 .It %mem
203 The percentage of real memory used by this process.
204 .It flags
205 The flags associated with the process as in
206 the include file
207 .Aq Pa sys/proc.h :
208 .Bl -column P_NOCLDSTOP P_NOCLDSTOP
209 .It Dv "P_ADVLOCK" Ta No "0x00001       Process may hold a POSIX advisory lock"
210 .It Dv "P_CONTROLT" Ta No "0x00002      Has a controlling terminal"
211 .It Dv "P_INMEM" Ta No "0x00004         Loaded into memory"
212 .It Dv "P_NOCLDSTOP" Ta No "0x00008     No SIGCHLD when children stop"
213 .It Dv "P_PPWAIT" Ta No "0x00010        Parent is waiting for child to exec/exit"
214 .It Dv "P_PROFIL" Ta No "0x00020        Has started profiling"
215 .It Dv "P_SELECT" Ta No "0x00040        Selecting; wakeup/waiting danger"
216 .It Dv "P_SINTR" Ta No "0x00080         Sleep is interruptible"
217 .It Dv "P_SUGID" Ta No "0x00100         Had set id privileges since last exec"
218 .It Dv "P_SYSTEM" Ta No "0x00200        System proc: no sigs, stats or swapping"
219 .It Dv "P_TIMEOUT" Ta No "0x00400       Timing out during sleep"
220 .It Dv "P_TRACED" Ta No "0x00800        Debugged process being traced"
221 .It Dv "P_WAITED" Ta No "0x01000        Debugging process has waited for child"
222 .It Dv "P_WEXIT" Ta No "0x02000         Working on exiting"
223 .It Dv "P_EXEC" Ta No "0x04000          Process called exec"
224 .It Dv "P_OWEUPC" Ta No "0x20000        Owe process an addupc() call at next ast"
225 .It Dv "P_SWAPPING" Ta No "0x40000      Process is being swapped"
226 .El
227 .It lim
228 The soft limit on memory used, specified via a call to
229 .Xr setrlimit 2 .
230 .It lstart
231 The exact time the command started, using the ``%c'' format described in
232 .Xr strftime 3 .
233 .It lvl
234 The LOMAC level of the process.
235 .It mtxname
236 The name of the
237 .Xr mutex 9
238 that the process is currently blocked on.
239 If the name is invalid or unknown, then
240 .Dq ???\&
241 is displayed.
242 .It mwchan
243 The event name if the process is blocked normally, or the mutex name if
244 the process is blocked on a mutex.  See the wchan and mtxname keywords
245 for details.
246 .It nice
247 The process scheduling increment (see
248 .Xr setpriority 2 ) .
249 .It rss
250 the real memory (resident set) size of the process (in 1024 byte units).
251 .It start
252 The time the command started.
253 If the command started less than 24 hours ago, the start time is
254 displayed using the ``%l:ps.1p'' format described in
255 .Xr strftime 3 .
256 If the command started less than 7 days ago, the start time is
257 displayed using the ``%a6.15p'' format.
258 Otherwise, the start time is displayed using the ``%e%b%y'' format.
259 .It state
260 The state is given by a sequence of letters, for example,
261 .Dq Tn RWNA .
262 The first letter indicates the run state of the process:
263 .Pp
264 .Bl -tag -width indent -compact
265 .It D
266 Marks a process in disk (or other short term, uninterruptible) wait.
267 .It I
268 Marks a process that is idle (sleeping for longer than about 20 seconds).
269 .It J
270 Marks a process which is in
271 .Xr jail 2 .
272 The hostname of the prison can be found in
273 .Ql Li /proc/<pid>/status .
274 .It M
275 Marks a process that is waiting to acquire a mutex.
276 .It R
277 Marks a runnable process.
278 .It S
279 Marks a process that is sleeping for less than about 20 seconds.
280 .It T
281 Marks a stopped process.
282 .It Z
283 Marks a dead process (a ``zombie'').
284 .El
285 .Pp
286 Additional characters after these, if any, indicate additional state
287 information:
288 .Pp
289 .Bl -tag -width indent -compact
290 .It +
291 The process is in the foreground process group of its control terminal.
292 .It <
293 The process has raised
294 .Tn CPU
295 scheduling priority.
296 .It >
297 The process has specified a soft limit on memory requirements and is
298 currently exceeding that limit; such a process is (necessarily) not
299 swapped.
300 .It A
301 the process has asked for random page replacement
302 .Pf ( Dv MADV_RANDOM ,
303 from
304 .Xr madvise 2 ,
305 for example,
306 .Xr lisp 1
307 in a garbage collect).
308 .It E
309 The process is trying to exit.
310 .It L
311 The process has pages locked in core (for example, for raw
312 .Tn I/O ) .
313 .It N
314 The process has reduced
315 .Tn CPU
316 scheduling priority (see
317 .Xr setpriority 2 ) .
318 .It S
319 The process has asked for
320 .Tn FIFO
321 page replacement
322 .Pf ( Dv MADV_SEQUENTIAL ,
323 from
324 .Xr madvise 2 ,
325 for example, a large image processing program using virtual memory to
326 sequentially address voluminous data).
327 .It s
328 The process is a session leader.
329 .It V
330 The process is suspended during a
331 .Xr vfork .
332 .It W
333 The process is swapped out.
334 .It X
335 The process is being traced or debugged.
336 .El
337 .It tt
338 An abbreviation for the pathname of the controlling terminal, if any.
339 The abbreviation consists of the three letters following
340 .Pa /dev/tty ,
341 or, for the console, ``con''.
342 This is followed by a ``-'' if the process can no longer reach that
343 controlling terminal (i.e., it has been revoked).
344 .It wchan
345 The event (an address in the system) on which a process waits.
346 When printed numerically, the initial part of the address is
347 trimmed off and the result is printed in hex, for example, 0x80324000 prints
348 as 324000.
349 .El
350 .Pp
351 When printing using the command keyword, a process that has exited and
352 has a parent that has not yet waited for the process (in other words, a zombie)
353 is listed as ``<defunct>'', and a process which is blocked while trying
354 to exit is listed as ``<exiting>''.
355 The
356 .Nm
357 utility
358 makes an educated guess as to the file name and arguments given when the
359 process was created by examining memory or the swap area.
360 The method is inherently somewhat unreliable and in any event a process
361 is entitled to destroy this information, so the names cannot be depended
362 on too much.
363 The ucomm (accounting) keyword can, however, be depended on.
364 .Sh KEYWORDS
365 The following is a complete list of the available keywords and their
366 meanings.
367 Several of them have aliases (keywords which are synonyms).
368 .Pp
369 .Bl -tag -width sigignore -compact
370 .It %cpu
371 percentage cpu usage (alias pcpu)
372 .It %mem
373 percentage memory usage (alias pmem)
374 .It acflag
375 accounting flag (alias acflg)
376 .It args
377 command and arguments
378 .It comm
379 command 
380 .It command
381 command and arguments
382 .It cpu
383 short-term cpu usage factor (for scheduling)
384 .It etime
385 elapsed running time
386 .It flags
387 the process flags, in hexadecimal (alias f)
388 .It inblk
389 total blocks read (alias inblock)
390 .It jobc
391 job control count
392 .It ktrace
393 tracing flags
394 .It lim
395 memoryuse limit
396 .It logname
397 login name of user who started the process
398 .It lstart
399 time started
400 .It lvl
401 LOMAC level
402 .It majflt
403 total page faults
404 .It minflt
405 total page reclaims
406 .It msgrcv
407 total messages received (reads from pipes/sockets)
408 .It msgsnd
409 total messages sent (writes on pipes/sockets)
410 .It mtxname
411 .Xr mutex 9
412 currently blocked on (as a symbolic name)
413 .It mwchan
414 wait channel or mutex currently blocked on
415 .It nice
416 nice value (alias ni)
417 .It nivcsw
418 total involuntary context switches
419 .It nsigs
420 total signals taken (alias nsignals)
421 .It nswap
422 total swaps in/out
423 .It nvcsw
424 total voluntary context switches
425 .It nwchan
426 wait channel (as an address)
427 .It oublk
428 total blocks written (alias oublock)
429 .It paddr
430 swap address
431 .It pagein
432 pageins (same as majflt)
433 .It pgid
434 process group number
435 .It pid
436 process
437 .Tn ID
438 .It poip
439 pageouts in progress
440 .It ppid
441 parent process
442 .Tn ID
443 .It pri
444 scheduling priority
445 .It re
446 core residency time (in seconds; 127 = infinity)
447 .It rgid
448 real group
449 .Tn ID
450 .It rgroup
451 group name (from rgid)
452 .It rlink
453 reverse link on run queue, or 0
454 .It rss
455 resident set size
456 .It rtprio
457 realtime priority (101 = not a realtime process)
458 .It ruid
459 real user
460 .Tn ID
461 .It ruser
462 user name (from ruid)
463 .It sid
464 session
465 .Tn ID
466 .It sig
467 pending signals (alias pending)
468 .It sigcatch
469 caught signals (alias caught)
470 .It sigignore
471 ignored signals (alias ignored)
472 .It sigmask
473 blocked signals (alias blocked)
474 .It sl
475 sleep time (in seconds; 127 = infinity)
476 .It start
477 time started
478 .It state
479 symbolic process state (alias stat)
480 .It svgid
481 saved gid from a setgid executable
482 .It svuid
483 saved uid from a setuid executable
484 .It tdev
485 control terminal device number
486 .It time
487 accumulated cpu time, user + system (alias cputime)
488 .It tpgid
489 control terminal process group
490 .Tn ID
491 .\".It trss
492 .\"text resident set size (in Kbytes)
493 .It tsid
494 control terminal session
495 .Tn ID
496 .It tsiz
497 text size (in Kbytes)
498 .It tt
499 control terminal name (two letter abbreviation)
500 .It tty
501 full name of control terminal
502 .It uprocp
503 process pointer
504 .It ucomm
505 name to be used for accounting
506 .It uid
507 effective user
508 .Tn ID
509 .It upr
510 scheduling priority on return from system call (alias usrpri)
511 .It user
512 user name (from uid)
513 .It vsz
514 virtual size in Kbytes (alias vsize)
515 .It wchan
516 wait channel (as a symbolic name)
517 .It xstat
518 exit or stop status (valid only for stopped or zombie process)
519 .El
520 .Sh ENVIRONMENT
521 The following environment variables affect the execution of
522 .Nm :
523 .Bl -tag -width ".Ev COLUMNS"
524 .It Ev COLUMNS
525 If set, specifies the user's preferred output width in column positions.
526 By default,
527 .Nm
528 attempts to automatically determine the terminal width.
529 .El
530 .Sh FILES
531 .Bl -tag -width /var/db/kvm_kernel.db -compact
532 .It Pa /dev/kmem
533 default kernel memory
534 .It Pa /dev/lomac
535 interface used to query the
536 .Xr lomac 4
537 KLD
538 .It Pa /var/run/dev.db
539 /dev name database
540 .It Pa /var/db/kvm_kernel.db
541 system namelist database
542 .It Pa /boot/kernel/kernel
543 default system namelist
544 .It Pa /proc
545 the mount point of
546 .Xr procfs 5
547 .El
548 .Sh SEE ALSO
549 .Xr kill 1 ,
550 .Xr w 1 ,
551 .Xr kvm 3 ,
552 .Xr strftime 3 ,
553 .Xr lomac 4 ,
554 .Xr procfs 5 ,
555 .Xr pstat 8 ,
556 .Xr sysctl 8 ,
557 .Xr mutex 9
558 .Sh HISTORY
559 The
560 .Nm
561 command appeared in
562 .At v4 .
563 .Sh BUGS
564 Since
565 .Nm
566 cannot run faster than the system and is run as any other scheduled
567 process, the information it displays can never be exact.