xref: /freebsd/bin/ps/ps.1 (revision 0f8f86b71f022b803e99151c19db81b280f245dc)
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 aCcefHhjlmrSTuvwxZ
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.Oo Fl p Ar pid Ns Xo
49.Op , Ns Ar pid Ns No ...
50.Xc
51.Oc
52.Op Fl t Ar tty
53.Oo Fl U Ar username Ns Xo
54.Op , Ns Ar username Ns No ...
55.Xc
56.Oc
57.Nm
58.Op Fl L
59.Sh DESCRIPTION
60The
61.Nm
62utility
63displays a header line followed by lines containing information about your
64processes that have controlling terminals.
65This information is sorted by controlling terminal, then by process
66.Tn ID .
67.Pp
68The information displayed is selected based on a set of keywords (see the
69.Fl L
70.Fl O
71and
72.Fl o
73options).
74The default output format includes, for each process, the process'
75.Tn ID ,
76controlling terminal, cpu time (including both user and system time),
77state, and associated command.
78.Pp
79The process file system (see
80.Xr procfs 5 )
81should be mounted when
82.Nm
83is executed, otherwise not all information will be available.
84.Pp
85The options are as follows:
86.Bl -tag -width indent
87.It Fl a
88Display information about other users' processes as well as your own.
89This can be disabled by setting the
90.Va security.bsd.see_other_uids
91sysctl to zero.
92.It Fl c
93Change the ``command'' column output to just contain the executable name,
94rather than the full command line.
95.It Fl C
96Change the way the cpu percentage is calculated by using a ``raw''
97cpu calculation that ignores ``resident'' time (this normally has
98no effect).
99.It Fl e
100Display the environment as well.
101.It Fl f
102Show commandline and environment information about swapped out processes.
103This option is honored only if the uid of the user is 0.
104.It Fl H
105Show all of the
106.Em kernel visible
107threads associated with each process.  Depending on the threading package that
108is in use, this may show only the process, only the kernel scheduled entities,
109or all of the process threads.
110.It Fl h
111Repeat the information header as often as necessary to guarantee one
112header per page of information.
113.It Fl j
114Print information associated with the following keywords:
115user, pid, ppid, pgid, jobc, state, tt, time and command.
116.It Fl L
117List the set of available keywords.
118.It Fl l
119Display information associated with the following keywords:
120uid, pid, ppid, cpu, pri, nice, vsz, rss, mwchan, state, tt, time
121and command.
122.It Fl M
123Extract values associated with the name list from the specified core
124instead of the default
125.Pa /dev/kmem .
126.It Fl m
127Sort by memory usage, instead of by process
128.Tn ID .
129.It Fl N
130Extract the name list from the specified system instead of the default
131.Pa /boot/kernel/kernel .
132.It Fl O
133Add the information associated with the space or comma separated list
134of keywords specified, after the process
135.Tn ID ,
136in the default information
137display.
138Keywords may be appended with an equals (``='') sign and a string.
139This causes the printed header to use the specified string instead of
140the standard header.
141.It Fl o
142Display information associated with the space or comma separated
143list of keywords specified.
144Multiple keywords may also be given in the form of more than one
145.Fl o
146option.
147Keywords may be appended with an equals (``='') sign and a string.
148This causes the printed header to use the specified string instead of
149the standard header.
150.It Fl p
151Display information associated with the specified process
152.Tn ID(s) .
153.It Fl r
154Sort by current cpu usage, instead of by process
155.Tn ID .
156.It Fl S
157Change the way the process time is calculated by summing all exited
158children to their parent process.
159.It Fl T
160Display information about processes attached to the device associated
161with the standard input.
162.It Fl t
163Display information about processes attached to the specified terminal
164device.
165.It Fl U
166Display the processes belonging to the specified
167.Ar username Ns (s) .
168.It Fl u
169Display information associated with the following keywords:
170user, pid, %cpu, %mem, vsz, rss, tt, state, start, time and command.
171The
172.Fl u
173option implies the
174.Fl r
175option.
176.It Fl v
177Display information associated with the following keywords:
178pid, state, time, sl, re, pagein, vsz, rss, lim, tsiz,
179%cpu, %mem and command.
180The
181.Fl v
182option implies the
183.Fl m
184option.
185.It Fl w
186Use 132 columns to display information, instead of the default which
187is your window size.
188If the
189.Fl w
190option is specified more than once,
191.Nm
192will use as many columns as necessary without regard for your window size.
193.It Fl x
194Display information about processes without controlling terminals.
195.It Fl Z
196Add label to the list of keywords for which
197.Nm
198will display information.
199.El
200.Pp
201A complete list of the available keywords are listed below.
202Some of these keywords are further specified as follows:
203.Bl -tag -width lockname
204.It %cpu
205The cpu utilization of the process; this is a decaying average over up to
206a minute of previous (real) time.
207Since the time base over which this is computed varies (since processes may
208be very young) it is possible for the sum of all
209.Tn \&%CPU
210fields to exceed 100%.
211.It %mem
212The percentage of real memory used by this process.
213.It flags
214The flags associated with the process as in
215the include file
216.In sys/proc.h :
217.Bl -column P_STOPPED_SINGLE 0x4000000
218.It Dv "P_ADVLOCK" Ta No "0x00001	Process may hold a POSIX advisory lock"
219.It Dv "P_CONTROLT" Ta No "0x00002	Has a controlling terminal"
220.It Dv "P_KTHREAD" Ta No "0x00004	Kernel thread"
221.It Dv "P_NOLOAD" Ta No "0x00008	Ignore during load avg calculations"
222.It Dv "P_PPWAIT" Ta No "0x00010	Parent is waiting for child to exec/exit"
223.It Dv "P_PROFIL" Ta No "0x00020	Has started profiling"
224.It Dv "P_STOPPROF" Ta No "0x00040	Has thread in requesting to stop prof"
225.It Dv "P_SUGID" Ta No "0x00100		Had set id privileges since last exec"
226.It Dv "P_SYSTEM" Ta No "0x00200	System proc: no sigs, stats or swapping"
227.It Dv "P_SINGLE_EXIT" Ta No "0x00400	Threads suspending should exit, not wait"
228.It Dv "P_TRACED" Ta No "0x00800	Debugged process being traced"
229.It Dv "P_WAITED" Ta No "0x01000	Someone is waiting for us"
230.It Dv "P_WEXIT" Ta No "0x02000		Working on exiting"
231.It Dv "P_EXEC" Ta No "0x04000		Process called exec"
232.It Dv "P_SA" Ta No "0x08000		Using scheduler activations"
233.It Dv "P_CONTINUED" Ta No "0x10000	Proc has continued from a stopped state"
234.It Dv "P_STOPPED_SIG" Ta No "0x20000	Stopped due to SIGSTOP/SIGTSTP"
235.It Dv "P_STOPPED_TRACE" Ta No "0x40000	Stopped because of tracing"
236.It Dv "P_STOPPED_SINGLE" Ta No "0x80000	Only one thread can continue"
237.It Dv "P_PROTECTED" Ta No "0x100000	Do not kill on memory overcommit"
238.It Dv "P_SIGEVENT" Ta No "0x200000	Process pending signals changed"
239.It Dv "P_JAILED" Ta No "0x1000000	Process is in jail"
240.It Dv "P_INEXEC" Ta No "0x4000000	Process is in execve()"
241.El
242.It label
243The MAC label of the process.
244.It lim
245The soft limit on memory used, specified via a call to
246.Xr setrlimit 2 .
247.It lstart
248The exact time the command started, using the ``%c'' format described in
249.Xr strftime 3 .
250.It lockname
251The name of the lock that the process is currently blocked on.
252If the name is invalid or unknown, then
253.Dq ???\&
254is displayed.
255.It mwchan
256The event name if the process is blocked normally, or the lock name if
257the process is blocked on a lock.
258See the wchan and lockname keywords
259for details.
260.It nice
261The process scheduling increment (see
262.Xr setpriority 2 ) .
263.It rss
264the real memory (resident set) size of the process (in 1024 byte units).
265.It start
266The time the command started.
267If the command started less than 24 hours ago, the start time is
268displayed using the ``%l:ps.1p'' format described in
269.Xr strftime 3 .
270If the command started less than 7 days ago, the start time is
271displayed using the ``%a6.15p'' format.
272Otherwise, the start time is displayed using the ``%e%b%y'' format.
273.It state
274The state is given by a sequence of characters, for example,
275.Dq Tn RWNA .
276The first character indicates the run state of the process:
277.Pp
278.Bl -tag -width indent -compact
279.It D
280Marks a process in disk (or other short term, uninterruptible) wait.
281.It I
282Marks a process that is idle (sleeping for longer than about 20 seconds).
283.It L
284Marks a process that is waiting to acquire a lock.
285.It R
286Marks a runnable process.
287.It S
288Marks a process that is sleeping for less than about 20 seconds.
289.It T
290Marks a stopped process.
291.It W
292Marks an idle interrupt thread.
293.It Z
294Marks a dead process (a ``zombie'').
295.El
296.Pp
297Additional characters after these, if any, indicate additional state
298information:
299.Pp
300.Bl -tag -width indent -compact
301.It +
302The process is in the foreground process group of its control terminal.
303.It <
304The process has raised
305.Tn CPU
306scheduling priority.
307.It E
308The process is trying to exit.
309.It J
310Marks a process which is in
311.Xr jail 2 .
312The hostname of the prison can be found in
313.Ql /proc/<pid>/status .
314.It L
315The process has pages locked in core (for example, for raw
316.Tn I/O ) .
317.It N
318The process has reduced
319.Tn CPU
320scheduling priority (see
321.Xr setpriority 2 ) .
322.It s
323The process is a session leader.
324.It V
325The process is suspended during a
326.Xr vfork 2 .
327.It W
328The process is swapped out.
329.It X
330The process is being traced or debugged.
331.El
332.It tt
333An abbreviation for the pathname of the controlling terminal, if any.
334The abbreviation consists of the three letters following
335.Pa /dev/tty ,
336or, for the console, ``con''.
337This is followed by a ``-'' if the process can no longer reach that
338controlling terminal (i.e., it has been revoked).
339.It wchan
340The event (an address in the system) on which a process waits.
341When printed numerically, the initial part of the address is
342trimmed off and the result is printed in hex, for example, 0x80324000 prints
343as 324000.
344.El
345.Pp
346When printing using the command keyword, a process that has exited and
347has a parent that has not yet waited for the process (in other words, a zombie)
348is listed as ``<defunct>'', and a process which is blocked while trying
349to exit is listed as ``<exiting>''.
350The
351.Nm
352utility
353makes an educated guess as to the file name and arguments given when the
354process was created by examining memory or the swap area.
355The method is inherently somewhat unreliable and in any event a process
356is entitled to destroy this information, so the names cannot be depended
357on too much.
358The ucomm (accounting) keyword can, however, be depended on.
359.Sh KEYWORDS
360The following is a complete list of the available keywords and their
361meanings.
362Several of them have aliases (keywords which are synonyms).
363.Pp
364.Bl -tag -width sigignore -compact
365.It %cpu
366percentage cpu usage (alias pcpu)
367.It %mem
368percentage memory usage (alias pmem)
369.It acflag
370accounting flag (alias acflg)
371.It args
372command and arguments
373.It comm
374command
375.It command
376command and arguments
377.It cpu
378short-term cpu usage factor (for scheduling)
379.It etime
380elapsed running time
381.It flags
382the process flags, in hexadecimal (alias f)
383.It inblk
384total blocks read (alias inblock)
385.It jobc
386job control count
387.It ktrace
388tracing flags
389.It label
390MAC label
391.It lim
392memoryuse limit
393.It logname
394login name of user who started the process
395.It lstart
396time started
397.It majflt
398total page faults
399.It minflt
400total page reclaims
401.It msgrcv
402total messages received (reads from pipes/sockets)
403.It msgsnd
404total messages sent (writes on pipes/sockets)
405.It lockname
406lock currently blocked on (as a symbolic name)
407.It mwchan
408wait channel or lock currently blocked on
409.It nice
410nice value (alias ni)
411.It nivcsw
412total involuntary context switches
413.It nsigs
414total signals taken (alias nsignals)
415.It nswap
416total swaps in/out
417.It nvcsw
418total voluntary context switches
419.It nwchan
420wait channel (as an address)
421.It oublk
422total blocks written (alias oublock)
423.It paddr
424swap address
425.It pagein
426pageins (same as majflt)
427.It pgid
428process group number
429.It pid
430process
431.Tn ID
432.It poip
433pageouts in progress
434.It ppid
435parent process
436.Tn ID
437.It pri
438scheduling priority
439.It re
440core residency time (in seconds; 127 = infinity)
441.It rgid
442real group
443.Tn ID
444.It rgroup
445group name (from rgid)
446.It rlink
447reverse link on run queue, or 0
448.It rss
449resident set size
450.It rtprio
451realtime priority (101 = not a realtime process)
452.It ruid
453real user
454.Tn ID
455.It ruser
456user name (from ruid)
457.It sid
458session
459.Tn ID
460.It sig
461pending signals (alias pending)
462.It sigcatch
463caught signals (alias caught)
464.It sigignore
465ignored signals (alias ignored)
466.It sigmask
467blocked signals (alias blocked)
468.It sl
469sleep time (in seconds; 127 = infinity)
470.It start
471time started
472.It state
473symbolic process state (alias stat)
474.It svgid
475saved gid from a setgid executable
476.It svuid
477saved uid from a setuid executable
478.It tdev
479control terminal device number
480.It time
481accumulated cpu time, user + system (alias cputime)
482.It tpgid
483control terminal process group
484.Tn ID
485.\".It trss
486.\"text resident set size (in Kbytes)
487.It tsid
488control terminal session
489.Tn ID
490.It tsiz
491text size (in Kbytes)
492.It tt
493control terminal name (two letter abbreviation)
494.It tty
495full name of control terminal
496.It uprocp
497process pointer
498.It ucomm
499name to be used for accounting
500.It uid
501effective user
502.Tn ID
503.It upr
504scheduling priority on return from system call (alias usrpri)
505.It user
506user name (from uid)
507.It vsz
508virtual size in Kbytes (alias vsize)
509.It wchan
510wait channel (as a symbolic name)
511.It xstat
512exit or stop status (valid only for stopped or zombie process)
513.El
514.Sh ENVIRONMENT
515The following environment variables affect the execution of
516.Nm :
517.Bl -tag -width ".Ev COLUMNS"
518.It Ev COLUMNS
519If set, specifies the user's preferred output width in column positions.
520By default,
521.Nm
522attempts to automatically determine the terminal width.
523.El
524.Sh FILES
525.Bl -tag -width /var/db/kvm_kernel.db -compact
526.It Pa /dev/kmem
527default kernel memory
528.It Pa /dev/lomac
529interface used to query the
530.Xr lomac 4
531KLD
532.It Pa /var/run/dev.db
533/dev name database
534.It Pa /var/db/kvm_kernel.db
535system namelist database
536.It Pa /boot/kernel/kernel
537default system namelist
538.It Pa /proc
539the mount point of
540.Xr procfs 5
541.El
542.Sh SEE ALSO
543.Xr kill 1 ,
544.Xr w 1 ,
545.Xr kvm 3 ,
546.Xr strftime 3 ,
547.Xr lomac 4 ,
548.Xr procfs 5 ,
549.Xr pstat 8 ,
550.Xr sysctl 8 ,
551.Xr mutex 9
552.Sh HISTORY
553The
554.Nm
555command appeared in
556.At v4 .
557.Sh BUGS
558Since
559.Nm
560cannot run faster than the system and is run as any other scheduled
561process, the information it displays can never be exact.
562