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