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