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