xref: /dragonfly/bin/ps/ps.1 (revision f9993810)
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. Neither the name of the University nor the names of its contributors
13.\"    may be used to endorse or promote products derived from this software
14.\"    without specific prior written permission.
15.\"
16.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26.\" SUCH DAMAGE.
27.\"
28.\"     @(#)ps.1	8.3 (Berkeley) 4/18/94
29.\" $FreeBSD: src/bin/ps/ps.1,v 1.24.2.7 2002/06/20 22:43:33 charnier Exp $
30.\"
31.Dd January 1, 2021
32.Dt PS 1
33.Os
34.Sh NAME
35.Nm ps
36.Nd process status
37.Sh SYNOPSIS
38.Nm
39.Op Fl AaCcefHhjlmrRSTuvwx
40.Op Fl M Ar core
41.Op Fl N Ar system
42.Op Fl O Ar fmt
43.Op Fl o Ar fmt
44.Op Fl p Ar pid
45.Op Fl t Ar tty
46.Op Fl U Ar username
47.Nm
48.Op Fl L
49.Sh DESCRIPTION
50The
51.Nm
52utility
53displays a header line followed by lines containing information about your
54processes that have controlling terminals.
55This information is sorted by controlling terminal, then by process ID.
56.Pp
57The information displayed is selected based on a set of keywords (see the
58.Fl L
59.Fl O
60and
61.Fl o
62options).
63The default output format includes, for each process, the process' ID,
64controlling terminal, CPU time (including both user and system time),
65state, and associated command.
66.Pp
67The process file system (see
68.Xr procfs 5 )
69should be mounted when
70.Nm
71is executed, otherwise not all information will be available.
72.Pp
73The options are as follows:
74.Bl -tag -width indent
75.It Fl a
76Display information about other users' processes as well as your own.
77This can be disabled by setting the
78.Va security.ps_showallprocs
79sysctl to zero.
80.It Fl A
81Same as
82.Fl ax .
83.It Fl c
84Change the ``command'' column output to just contain the executable name,
85rather than the full command line.
86.It Fl C
87Change the way the CPU percentage is calculated by using a ``raw''
88CPU calculation that ignores ``resident'' time (this normally has
89no effect).
90.It Fl e
91Display the environment as well.
92.It Fl f
93Show commandline and environment information about swapped out processes.
94This option is honored only if the uid of the user is 0.
95.It Fl H
96Print one line per lightweight process (LWP) instead of one line per process.
97When this option is set and the
98.Fl o
99option is not set, the
100.Cm tid
101column is inserted in the output format after the
102.Cm pid
103one.
104.It Fl h
105Repeat the information header as often as necessary to guarantee one
106header per page of information.
107.It Fl j
108Print information associated with the following keywords:
109.Cm user , pid , ppid , pgid , sess , jobc , state , tt , time ,
110and
111.Cm command .
112.It Fl L
113List the set of available keywords.
114.It Fl l
115Display information associated with the following keywords:
116.Cm uid , pid , ppid , cpu , pri , nice , vsz , rss , wchan , state ,
117.Cm tt , time ,
118and
119.Cm command .
120.It Fl M
121Extract values associated with the name list from the specified core
122instead of the default
123.Pa /dev/kmem .
124.It Fl m
125Sort by memory usage, instead of by process ID.
126.It Fl N
127Extract the name list from the specified system instead of the default
128.Pa /boot/kernel .
129.It Fl O
130Add the information associated with the space or comma separated list
131of keywords specified, after the process ID,
132in the default information
133display.
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 o
138Display information associated with the space or comma separated list
139of keywords specified.
140Keywords may be appended with an equals (``='') sign and a string.
141This causes the printed header to use the specified string instead of
142the standard header.
143.It Fl p
144Display information associated with the specified process ID.
145.It Fl r
146Sort by current CPU usage, instead of by process ID.
147.It Fl R
148Subsort by parent/child chain.  This very useful option makes
149the parent/child associations clear and understandable.
150If used in combination with
151.Fl p
152then all children of the specified process will be output
153recursively in addition to the process itself.
154.It Fl S
155Change the way the process time is calculated by summing all exited
156children to their parent process.
157.It Fl T
158Display information about processes attached to the device associated
159with the standard input.
160.It Fl t
161Display information about processes attached to the specified terminal
162device.
163.It Fl U
164Display the processes belonging to the specified
165.Ar username .
166.It Fl u
167Display information associated with the following keywords:
168.Cm user , pid, %cpu , %mem , vsz , rss , tt , state , start , time ,
169and
170.Cm command .
171The
172.Fl u
173option implies the
174.Fl r
175option.
176.It Fl v
177Display information associated with the following keywords:
178.Cm pid , state , time , sl , re , pagein , vsz , rss , lim , tsiz ,
179.Cm %cpu , %mem
180and
181.Cm command .
182The
183.Fl v
184option implies the
185.Fl m
186option.
187.It Fl w
188Use 132 columns to display information, instead of the default which
189is your window size.
190If the
191.Fl w
192option is specified more than once,
193.Nm
194will use as many columns as necessary without regard for your window size.
195.It Fl x
196Display information about processes without controlling terminals.
197.El
198.Pp
199A complete list of the available keywords are listed below.
200Some of these keywords are further specified as follows:
201.Bl -tag -width ".Cm lstart"
202.It Cm %cpu
203The CPU utilization of the process; this is a decaying average over up to
204a minute of previous (real) time.
205Since the time base over which this is computed varies (since processes may
206be very young) it is possible for the sum of all
207.Cm %cpu
208fields to exceed 100%.
209.It Cm %mem
210The percentage of real memory used by this process.
211.It Cm flags
212The flags associated with the process as in
213the include file
214.In sys/proc.h .
215.It Cm lim
216The soft limit on memory used, specified via a call to
217.Xr setrlimit 2 .
218.It Cm lstart
219The exact time the command started, using the ``%c'' format described in
220.Xr strftime 3 .
221.It Cm nice
222The process scheduling increment (see
223.Xr setpriority 2 ) .
224.It Cm rss
225the real memory (resident set) size of the process (in 1024 byte units).
226.It Cm start
227The time the command started.
228If the command started less than 24 hours ago, the start time is
229displayed using the ``%l:ps.1p'' format described in
230.Xr strftime 3 .
231If the command started less than 7 days ago, the start time is
232displayed using the ``%a6.15p'' format.
233Otherwise, the start time is displayed using the ``%e%b%y'' format.
234.It Cm state
235The state is given by a sequence of letters, for example,
236.Dq Li RWNA .
237The first letter indicates the run state of the process:
238.Pp
239.Bl -tag -width indent -compact
240.It Li B
241Marks a blocked kernel thread.
242.It Li D
243Marks a process in disk (or other short term, uninterruptible) wait.
244.It Li I
245Marks a process that is idle (sleeping for longer than about 20 seconds).
246.It Li J
247Marks a process which is in
248.Xr jail 2 .
249The hostname of the prison can be found in
250.Pa /proc/ Ns Ao Ar pid Ac Ns Pa /status .
251.It Li R
252Marks a runnable process and is followed by the CPU number.
253.It Li S
254Marks a process that is sleeping for less than about 20 seconds.
255.It Li T
256Marks a stopped process.
257.It Li y
258Marks a process with the RESTRICTEDROOT capability set (both SELF and EXEC).
259.It Li Y
260Marks a process with the RESTRICTEDROOT and the SENSITIVEROOT capabilities
261set (both SELF and EXEC).  Other capabilities are ignored.
262.It Li Z
263Marks a dead process (a
264.Dq zombie ) .
265.El
266.Pp
267Additional characters after these, if any, indicate additional state
268information:
269.Pp
270.Bl -tag -width indent -compact
271.It Li +
272The process is in the foreground process group of its control terminal.
273.It Li <
274The process has raised CPU scheduling priority.
275.It Li >
276The process has specified a soft limit on memory requirements and is
277currently exceeding that limit; such a process is (necessarily) not
278swapped.
279.It Li A
280the process has asked for random page replacement
281.Pf ( Dv MADV_RANDOM ,
282from
283.Xr madvise 2 ,
284for example,
285.Xr lisp 1
286in a garbage collect).
287.It Li E
288The process is trying to exit.
289.It Li N
290The process has reduced CPU scheduling priority (see
291.Xr setpriority 2 ) .
292.It Li S
293The process has asked for FIFO page replacement
294.Pf ( Dv MADV_SEQUENTIAL ,
295from
296.Xr madvise 2 ,
297for example, a large image processing program using virtual memory to
298sequentially address voluminous data).
299.It Li s
300The process is a session leader.
301.It Li V
302The process is suspended during a
303.Xr vfork 2 .
304.It Li W
305The process is swapped out.
306.It Li X
307The process is being traced or debugged.
308.El
309.It Cm tt
310An abbreviation for the pathname of the controlling terminal, if any.
311The abbreviation consists of the three letters following
312.Pa /dev/tty ,
313or, for the console, ``con''.
314This is followed by a ``-'' if the process can no longer reach that
315controlling terminal (i.e., it has been revoked).
316.It Cm wchan
317The event (an address in the system) on which a process waits.
318When printed numerically, the initial part of the address is
319trimmed off and the result is printed in hex, for example, 0x80324000 prints
320as 324000.  Note that blocked threads often only have ascii wchan's.
321.El
322.Pp
323When printing using the
324.Cm command
325keyword, a process that has exited and
326has a parent that has not yet waited for the process (in other words, a zombie)
327is listed as ``<defunct>'', and a process which is blocked while trying
328to exit is listed as ``<exiting>''.
329The
330.Nm
331utility
332makes an educated guess as to the file name and arguments given when the
333process was created by examining memory or the swap area.
334The method is inherently somewhat unreliable and in any event a process
335is entitled to destroy this information, so the names cannot be depended
336on too much.
337The
338.Cm ucomm
339(accounting) keyword can, however, be depended on.
340.Sh KEYWORDS
341The following is a complete list of the available keywords and their
342meanings.
343Several of them have aliases (keywords which are synonyms).
344.Pp
345.Bl -tag -width ".Cm sigignore" -compact
346.It Cm %cpu
347percentage CPU usage (alias
348.Cm pcpu )
349.It Cm %mem
350percentage memory usage (alias
351.Cm pmem )
352.It Cm acflag
353accounting flag (alias
354.Cm acflg )
355.It Cm batch
356batchness of the process (higher numbers mean less interactivity)
357.It Cm command
358command and arguments (alias
359.Cm args )
360.It Cm cpu
361short-term CPU usage factor (for scheduling)
362.It Cm f
363the process flags, in hexadecimal (alias
364.Cm flags )
365.It Cm inblk
366total blocks read (alias
367.Cm inblock )
368.It Cm jail
369jail ID
370.It Cm jobc
371job control count
372.It Cm ktrace
373tracing flags
374.\" .It Cm ktracep
375.\" tracing vnode
376.It Cm lastcpu
377CPU ID the process was last scheduled on
378.It Cm lim
379memoryuse limit
380.It Cm login
381login name of user who started the process (alias
382.Cm logname )
383.It Cm lstart
384time started
385.It Cm majflt
386total page faults
387.It Cm minflt
388total page reclaims
389.It Cm msgrcv
390total messages received (reads from pipes/sockets)
391.It Cm msgsnd
392total messages sent (writes on pipes/sockets)
393.It Cm nice
394nice value (alias
395.Cm ni )
396.It Cm nivcsw
397total involuntary context switches
398.It Cm nlwp
399number of lightweight processes
400.It Cm nsigs
401total signals taken (alias
402.Cm nsignals )
403.It Cm nswap
404total swaps in/out
405.It Cm nvcsw
406total voluntary context switches
407.It Cm nwchan
408wait channel (as an address)
409.It Cm oublk
410total blocks written (alias
411.Cm oublock )
412.It Cm p_ru
413resource usage (valid only for zombie)
414.It Cm paddr
415swap address
416.It Cm pagein
417pageins (same as
418.Cm majflt )
419.It Cm pgid
420process group number
421.It Cm pid
422process ID
423.It Cm ppid
424parent process ID
425.It Cm pri
426scheduling priority (lower == better)
427.It Cm re
428core residency time (in seconds; 127 = infinity)
429.It Cm rgid
430real group ID
431.\" .It Cm rlink
432.\" reverse link on run queue, or 0
433.It Cm rss
434resident set size
435.It Cm rsz
436resident set size + (text size / text use count) (alias
437.Cm rssize )
438.It Cm rtprio
439realtime priority (101 = not a realtime process)
440.It Cm ruid
441real user ID
442.It Cm ruser
443user name (from ruid)
444.It Cm sess
445session pointer
446.It Cm sig
447pending signals (alias
448.Cm pending )
449.It Cm sigcatch
450caught signals (alias
451.Cm caught )
452.It Cm sigignore
453ignored signals (alias
454.Cm ignored )
455.It Cm sigmask
456blocked signals (alias
457.Cm blocked )
458.It Cm sl
459sleep time (in seconds; 127 = infinity)
460.It Cm start
461time started
462.It Cm state
463symbolic process state (alias
464.Cm stat )
465.It Cm svgid
466saved gid from a setgid executable
467.It Cm svuid
468saved uid from a setuid executable
469.It Cm tdev
470control terminal device number
471.It Cm tdpri
472LWKT thread priority (0-31, 31 highest), and critical section count
473.It Cm tid
474thread ID (aka lightweight process ID)
475.It Cm time
476accumulated CPU time, user + system (alias
477.Cm cputime )
478.It Cm tpgid
479control terminal process group ID
480.\".It Cm trss
481.\"text resident set size (in Kbytes)
482.It Cm tsess
483control terminal session pointer
484.It Cm tsig
485pending thread signals
486.It Cm tsiz
487text size (in Kbytes)
488.It Cm tt
489control terminal name (two letter abbreviation)
490.It Cm tty
491full name of control terminal
492.It Cm ucomm
493name to be used for accounting (alias
494.Cm comm )
495.It Cm uid
496effective user ID
497.It Cm user
498user name (from uid)
499.It Cm vsz
500virtual size in Kbytes (alias
501.Cm vsize )
502.It Cm wchan
503wait channel (as a symbolic name)
504.It Cm xstat
505exit or stop status (valid only for stopped or zombie process)
506.El
507.Sh FILES
508.Bl -tag -width ".Pa /boot/kernel/kernel" -compact
509.It Pa /dev/kmem
510default kernel memory
511.It Pa /boot/kernel/kernel
512default system namelist
513.It Pa /proc
514the mount point of
515.Xr procfs 5
516.El
517.Sh SEE ALSO
518.Xr kill 1 ,
519.Xr w 1 ,
520.Xr kvm 3 ,
521.Xr strftime 3 ,
522.Xr procfs 5 ,
523.Xr pstat 8 ,
524.Xr sysctl 8
525.Sh HISTORY
526The
527.Nm
528command appeared in
529.At v3
530in section 8 of the manual.
531.Sh BUGS
532Since
533.Nm
534cannot run faster than the system and is run as any other scheduled
535process, the information it displays can never be exact.
536