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