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