xref: /freebsd/bin/ps/ps.1 (revision 99e8005137088aafb1350e23b113d69b01b0820f)
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, 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 lim
371memoryuse limit
372.It logname
373login name of user who started the process
374.It lstart
375time started
376.It majflt
377total page faults
378.It minflt
379total page reclaims
380.It msgrcv
381total messages received (reads from pipes/sockets)
382.It msgsnd
383total messages sent (writes on pipes/sockets)
384.It mtxname
385.Xr mutex 9
386currently blocked on (as a symbolic name)
387.It nice
388nice value (alias ni)
389.It nivcsw
390total involuntary context switches
391.It nsigs
392total signals taken (alias nsignals)
393.It nswap
394total swaps in/out
395.It nvcsw
396total voluntary context switches
397.It nwchan
398wait channel (as an address)
399.It oublk
400total blocks written (alias oublock)
401.It paddr
402swap address
403.It pagein
404pageins (same as majflt)
405.It pgid
406process group number
407.It pid
408process
409.Tn ID
410.It poip
411pageouts in progress
412.It ppid
413parent process
414.Tn ID
415.It pri
416scheduling priority
417.It re
418core residency time (in seconds; 127 = infinity)
419.It rgid
420real group
421.Tn ID
422.It rlink
423reverse link on run queue, or 0
424.It rss
425resident set size
426.It rtprio
427realtime priority (101 = not a realtime process)
428.It ruid
429real user
430.Tn ID
431.It ruser
432user name (from ruid)
433.It sid
434session
435.Tn ID
436.It sig
437pending signals (alias pending)
438.It sigcatch
439caught signals (alias caught)
440.It sigignore
441ignored signals (alias ignored)
442.It sigmask
443blocked signals (alias blocked)
444.It sl
445sleep time (in seconds; 127 = infinity)
446.It start
447time started
448.It state
449symbolic process state (alias stat)
450.It svgid
451saved gid from a setgid executable
452.It svuid
453saved uid from a setuid executable
454.It tdev
455control terminal device number
456.It time
457accumulated cpu time, user + system (alias cputime)
458.It tpgid
459control terminal process group
460.Tn ID
461.\".It trss
462.\"text resident set size (in Kbytes)
463.It tsid
464control terminal session
465.Tn ID
466.It tsiz
467text size (in Kbytes)
468.It tt
469control terminal name (two letter abbreviation)
470.It tty
471full name of control terminal
472.It uprocp
473process pointer
474.It ucomm
475name to be used for accounting
476.It uid
477effective user
478.Tn ID
479.It upr
480scheduling priority on return from system call (alias usrpri)
481.It user
482user name (from uid)
483.It vsz
484virtual size in Kbytes (alias vsize)
485.It wchan
486wait channel (as a symbolic name)
487.It xstat
488exit or stop status (valid only for stopped or zombie process)
489.El
490.Sh FILES
491.Bl -tag -width /var/db/kvm_kernel.db -compact
492.It Pa /dev
493special files and device names
494.It Pa /dev/drum
495default swap device
496.It Pa /dev/kmem
497default kernel memory
498.It Pa /var/run/dev.db
499/dev name database
500.It Pa /var/db/kvm_kernel.db
501system namelist database
502.It Pa /kernel
503default system namelist
504.It Pa /proc
505the mount point of
506.Xr procfs 5
507.El
508.Sh SEE ALSO
509.Xr kill 1 ,
510.Xr w 1 ,
511.Xr kvm 3 ,
512.Xr strftime 3 ,
513.Xr procfs 5 ,
514.Xr pstat 8 ,
515.Xr mutex 9
516.Sh BUGS
517Since
518.Nm
519cannot run faster than the system and is run as any other scheduled
520process, the information it displays can never be exact.
521