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