xref: /freebsd/bin/ps/ps.1 (revision 06064893b3c62c648518be78604fac29fc0d9d61)
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.\" 4. 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$
30.\"
31.Dd March 27, 2004
32.Dt PS 1
33.Os
34.Sh NAME
35.Nm ps
36.Nd process status
37.Sh SYNOPSIS
38.Nm
39.Op Fl aCcefHhjlmrSTuvwXxZ
40.Op Fl G Ar gid Ns Op , Ns Ar gid Ns Ar ...
41.Op Fl M Ar core
42.Op Fl N Ar system
43.Op Fl O Ar fmt
44.Op Fl o Ar fmt
45.Op Fl p Ar pid Ns Op , Ns Ar pid Ns Ar ...
46.Op Fl t Ar tty Ns Op , Ns Ar tty Ns Ar ...
47.Op Fl U Ar username Ns Op , Ns Ar username Ns Ar ...
48.Nm
49.Op Fl L
50.Sh DESCRIPTION
51The
52.Nm
53utility
54displays a header line, followed by lines containing information about
55all of your
56processes that have controlling terminals.
57.Pp
58A different set of processes can be selected for display by using any
59combination of the
60.Fl a , G , p , T , t ,
61and
62.Fl U
63options.
64If more than one of these options are given, then
65.Nm
66will select all processes which are matched by at least one of the
67given options.
68.Pp
69For the processes which have been selected for display,
70.Nm
71will usually display one line per process.
72The
73.Fl H
74option may result in multiple output lines (one line per thread) for
75some processes.
76By default all of these output lines are sorted first by controlling
77terminal, then by process ID.
78The
79.Fl m , r , u ,
80and
81.Fl v
82options will change the sort order.
83If more than one sorting option was given, then the selected processes
84will be sorted by the last sorting option which was specified.
85.Pp
86For the processes which have been selected for display, the information
87to display is selected based on a set of keywords (see the
88.Fl L , O ,
89and
90.Fl o
91options).
92The default output format includes, for each process, the process' ID,
93controlling terminal, CPU time (including both user and system time),
94state, and associated command.
95.Pp
96The process file system (see
97.Xr procfs 5 )
98should be mounted when
99.Nm
100is executed, otherwise not all information will be available.
101.Pp
102The options are as follows:
103.Bl -tag -width indent
104.It Fl a
105Display information about other users' processes as well as your own.
106This will skip any processes which do not have a controlling teminal,
107unless the
108.Fl x
109option is also specified.
110This can be disabled by setting the
111.Va security.bsd.see_other_uids
112sysctl to zero.
113.It Fl c
114Change the
115.Dq command
116column output to just contain the executable name,
117rather than the full command line.
118.It Fl C
119Change the way the CPU percentage is calculated by using a
120.Dq raw
121CPU calculation that ignores
122.Dq resident
123time (this normally has
124no effect).
125.It Fl e
126Display the environment as well.
127.It Fl f
128Show commandline and environment information about swapped out processes.
129This option is honored only if the UID of the user is 0.
130.It Fl G
131Display information about processes which are running with the specified
132real group IDs.
133.It Fl H
134Show all of the
135.Em kernel visible
136threads associated with each process.
137Depending on the threading package that
138is in use, this may show only the process, only the kernel scheduled entities,
139or all of the process threads.
140.It Fl h
141Repeat the information header as often as necessary to guarantee one
142header per page of information.
143.It Fl j
144Print information associated with the following keywords:
145.Cm user , pid , ppid , pgid , sid , jobc , state , tt , time ,
146and
147.Cm command .
148.It Fl L
149List the set of keywords available for the
150.Fl O
151and
152.Fl o
153options.
154.It Fl l
155Display information associated with the following keywords:
156.Cm uid , pid , ppid , cpu , pri , nice , vsz , rss , mwchan , state ,
157.Cm tt , time ,
158and
159.Cm command .
160.It Fl M
161Extract values associated with the name list from the specified core
162instead of the currently running system.
163.It Fl m
164Sort by memory usage, instead of the combination of controlling
165terminal and process ID.
166.It Fl N
167Extract the name list from the specified system instead of the default,
168which is the kernel image the system has booted from.
169.It Fl O
170Add the information associated with the space or comma separated list
171of keywords specified, after the process ID,
172in the default information
173display.
174Keywords may be appended with an equals
175.Pq Ql =
176sign and a string.
177This causes the printed header to use the specified string instead of
178the standard header.
179.It Fl o
180Display information associated with the space or comma separated
181list of keywords specified.
182Multiple keywords may also be given in the form of more than one
183.Fl o
184option.
185Keywords may be appended with an equals
186.Pq Ql =
187sign and a string.
188This causes the printed header to use the specified string instead of
189the standard header.
190.It Fl p
191Display information about processes which match the specified process IDs.
192.It Fl r
193Sort by current CPU usage, instead of the combination of controlling
194terminal and process ID.
195.It Fl S
196Change the way the process time is calculated by summing all exited
197children to their parent process.
198.It Fl T
199Display information about processes attached to the device associated
200with the standard input.
201.It Fl t
202Display information about processes attached to the specified terminal
203devices.
204.It Fl U
205Display the processes belonging to the specified usernames.
206.It Fl u
207Display information associated with the following keywords:
208.Cm user , pid , %cpu , %mem , vsz , rss , tt , state , start , time ,
209and
210.Cm command .
211The
212.Fl u
213option implies the
214.Fl r
215option.
216.It Fl v
217Display information associated with the following keywords:
218.Cm pid , state , time , sl , re , pagein , vsz , rss , lim , tsiz ,
219.Cm %cpu , %mem ,
220and
221.Cm command .
222The
223.Fl v
224option implies the
225.Fl m
226option.
227.It Fl w
228Use 132 columns to display information, instead of the default which
229is your window size.
230If the
231.Fl w
232option is specified more than once,
233.Nm
234will use as many columns as necessary without regard for your window size.
235.It Fl X
236When displaying processes matched by other options, skip any processes
237which do not have a controlling terminal.
238.It Fl x
239When displaying processes matched by other options, include processes
240which do not have a controlling terminal.
241This is the opposite of the
242.Fl X
243option.
244If both
245.Fl X
246and
247.Fl x
248are specified in the same command, then
249.Nm
250will use the one which was specified last.
251.It Fl Z
252Add
253.Xr mac 4
254label to the list of keywords for which
255.Nm
256will display information.
257.El
258.Pp
259A complete list of the available keywords are listed below.
260Some of these keywords are further specified as follows:
261.Bl -tag -width lockname
262.It Cm %cpu
263The CPU utilization of the process; this is a decaying average over up to
264a minute of previous (real) time.
265Since the time base over which this is computed varies (since processes may
266be very young) it is possible for the sum of all
267.Cm %cpu
268fields to exceed 100%.
269.It Cm %mem
270The percentage of real memory used by this process.
271.It Cm flags
272The flags associated with the process as in
273the include file
274.In sys/proc.h :
275.Bl -column P_STOPPED_SINGLE 0x4000000
276.It Dv "P_ADVLOCK" Ta No "0x00001	Process may hold a POSIX advisory lock"
277.It Dv "P_CONTROLT" Ta No "0x00002	Has a controlling terminal"
278.It Dv "P_KTHREAD" Ta No "0x00004	Kernel thread"
279.It Dv "P_NOLOAD" Ta No "0x00008	Ignore during load avg calculations"
280.It Dv "P_PPWAIT" Ta No "0x00010	Parent is waiting for child to exec/exit"
281.It Dv "P_PROFIL" Ta No "0x00020	Has started profiling"
282.It Dv "P_STOPPROF" Ta No "0x00040	Has thread in requesting to stop prof"
283.It Dv "P_SUGID" Ta No "0x00100		Had set id privileges since last exec"
284.It Dv "P_SYSTEM" Ta No "0x00200	System proc: no sigs, stats or swapping"
285.It Dv "P_SINGLE_EXIT" Ta No "0x00400	Threads suspending should exit, not wait"
286.It Dv "P_TRACED" Ta No "0x00800	Debugged process being traced"
287.It Dv "P_WAITED" Ta No "0x01000	Someone is waiting for us"
288.It Dv "P_WEXIT" Ta No "0x02000		Working on exiting"
289.It Dv "P_EXEC" Ta No "0x04000		Process called exec"
290.It Dv "P_SA" Ta No "0x08000		Using scheduler activations"
291.It Dv "P_CONTINUED" Ta No "0x10000	Proc has continued from a stopped state"
292.It Dv "P_STOPPED_SIG" Ta No "0x20000	Stopped due to SIGSTOP/SIGTSTP"
293.It Dv "P_STOPPED_TRACE" Ta No "0x40000	Stopped because of tracing"
294.It Dv "P_STOPPED_SINGLE" Ta No "0x80000	Only one thread can continue"
295.It Dv "P_PROTECTED" Ta No "0x100000	Do not kill on memory overcommit"
296.It Dv "P_SIGEVENT" Ta No "0x200000	Process pending signals changed"
297.It Dv "P_JAILED" Ta No "0x1000000	Process is in jail"
298.It Dv "P_INEXEC" Ta No "0x4000000	Process is in execve()"
299.El
300.It Cm label
301The MAC label of the process.
302.It Cm lim
303The soft limit on memory used, specified via a call to
304.Xr setrlimit 2 .
305.It Cm lstart
306The exact time the command started, using the
307.Ql %c
308format described in
309.Xr strftime 3 .
310.It Cm lockname
311The name of the lock that the process is currently blocked on.
312If the name is invalid or unknown, then
313.Dq ???\&
314is displayed.
315.It Cm mwchan
316The event name if the process is blocked normally, or the lock name if
317the process is blocked on a lock.
318See the wchan and lockname keywords
319for details.
320.It Cm nice
321The process scheduling increment (see
322.Xr setpriority 2 ) .
323.It Cm rss
324the real memory (resident set) size of the process (in 1024 byte units).
325.It Cm start
326The time the command started.
327If the command started less than 24 hours ago, the start time is
328displayed using the
329.Dq Li %l:ps.1p
330format described in
331.Xr strftime 3 .
332If the command started less than 7 days ago, the start time is
333displayed using the
334.Dq Li %a6.15p
335format.
336Otherwise, the start time is displayed using the
337.Dq Li %e%b%y
338format.
339.It Cm state
340The state is given by a sequence of characters, for example,
341.Dq Li RWNA .
342The first character indicates the run state of the process:
343.Pp
344.Bl -tag -width indent -compact
345.It Li D
346Marks a process in disk (or other short term, uninterruptible) wait.
347.It Li I
348Marks a process that is idle (sleeping for longer than about 20 seconds).
349.It Li L
350Marks a process that is waiting to acquire a lock.
351.It Li R
352Marks a runnable process.
353.It Li S
354Marks a process that is sleeping for less than about 20 seconds.
355.It Li T
356Marks a stopped process.
357.It Li W
358Marks an idle interrupt thread.
359.It Li Z
360Marks a dead process (a
361.Dq zombie ) .
362.El
363.Pp
364Additional characters after these, if any, indicate additional state
365information:
366.Pp
367.Bl -tag -width indent -compact
368.It Li +
369The process is in the foreground process group of its control terminal.
370.It Li <
371The process has raised CPU scheduling priority.
372.It Li E
373The process is trying to exit.
374.It Li J
375Marks a process which is in
376.Xr jail 2 .
377The hostname of the prison can be found in
378.Pa /proc/ Ns Ao Ar pid Ac Ns Pa /status .
379.It Li L
380The process has pages locked in core (for example, for raw
381.Tn I/O ) .
382.It Li N
383The process has reduced CPU scheduling priority (see
384.Xr setpriority 2 ) .
385.It Li s
386The process is a session leader.
387.It Li V
388The process is suspended during a
389.Xr vfork 2 .
390.It Li W
391The process is swapped out.
392.It Li X
393The process is being traced or debugged.
394.El
395.It Cm tt
396An abbreviation for the pathname of the controlling terminal, if any.
397The abbreviation consists of the three letters following
398.Pa /dev/tty ,
399or, for the console,
400.Dq Li con .
401This is followed by a
402.Ql -
403if the process can no longer reach that
404controlling terminal (i.e., it has been revoked).
405.It Cm wchan
406The event (an address in the system) on which a process waits.
407When printed numerically, the initial part of the address is
408trimmed off and the result is printed in hex, for example, 0x80324000 prints
409as 324000.
410.El
411.Pp
412When printing using the command keyword, a process that has exited and
413has a parent that has not yet waited for the process (in other words, a zombie)
414is listed as
415.Dq Li <defunct> ,
416and a process which is blocked while trying
417to exit is listed as
418.Dq Li <exiting> .
419If the command vector cannot be located (usually because it has not
420been set, as is the case of system processes and/or kernel threads)
421the command name is printed within square brackets.
422The
423.Nm
424utility
425makes an educated guess as to the file name and arguments given when the
426process was created by examining memory or the swap area.
427The method is inherently somewhat unreliable and in any event a process
428is entitled to destroy this information, so the names cannot be depended
429on too much.
430The ucomm (accounting) keyword can, however, be depended on.
431.Sh KEYWORDS
432The following is a complete list of the available keywords and their
433meanings.
434Several of them have aliases (keywords which are synonyms).
435.Pp
436.Bl -tag -width ".Cm sigignore" -compact
437.It Cm %cpu
438percentage CPU usage (alias
439.Cm pcpu )
440.It Cm %mem
441percentage memory usage (alias
442.Cm pmem )
443.It Cm acflag
444accounting flag (alias
445.Cm acflg )
446.It Cm args
447command and arguments
448.It Cm comm
449command
450.It Cm command
451command and arguments
452.It Cm cpu
453short-term CPU usage factor (for scheduling)
454.It Cm etime
455elapsed running time
456.It Cm flags
457the process flags, in hexadecimal (alias
458.Cm f )
459.It Cm inblk
460total blocks read (alias
461.Cm inblock )
462.It Cm jobc
463job control count
464.It Cm ktrace
465tracing flags
466.It Cm label
467MAC label
468.It Cm lim
469memoryuse limit
470.It Cm logname
471login name of user who started the process
472.It Cm lstart
473time started
474.It Cm majflt
475total page faults
476.It Cm minflt
477total page reclaims
478.It Cm msgrcv
479total messages received (reads from pipes/sockets)
480.It Cm msgsnd
481total messages sent (writes on pipes/sockets)
482.It Cm lockname
483lock currently blocked on (as a symbolic name)
484.It Cm mwchan
485wait channel or lock currently blocked on
486.It Cm nice
487nice value (alias
488.Cm ni )
489.It Cm nivcsw
490total involuntary context switches
491.It Cm nsigs
492total signals taken (alias
493.Cm nsignals )
494.It Cm nswap
495total swaps in/out
496.It Cm nvcsw
497total voluntary context switches
498.It Cm nwchan
499wait channel (as an address)
500.It Cm oublk
501total blocks written (alias
502.Cm oublock )
503.It Cm paddr
504swap address
505.It Cm pagein
506pageins (same as majflt)
507.It Cm pgid
508process group number
509.It Cm pid
510process ID
511.It Cm poip
512pageouts in progress
513.It Cm ppid
514parent process ID
515.It Cm pri
516scheduling priority
517.It Cm re
518core residency time (in seconds; 127 = infinity)
519.It Cm rgid
520real group ID
521.It Cm rgroup
522group name (from rgid)
523.It Cm rlink
524reverse link on run queue, or 0
525.It Cm rss
526resident set size
527.It Cm rtprio
528realtime priority (101 = not a realtime process)
529.It Cm ruid
530real user ID
531.It Cm ruser
532user name (from ruid)
533.It Cm sid
534session ID
535.It Cm sig
536pending signals (alias
537.Cm pending )
538.It Cm sigcatch
539caught signals (alias
540.Cm caught )
541.It Cm sigignore
542ignored signals (alias
543.Cm ignored )
544.It Cm sigmask
545blocked signals (alias
546.Cm blocked )
547.It Cm sl
548sleep time (in seconds; 127 = infinity)
549.It Cm start
550time started
551.It Cm state
552symbolic process state (alias
553.Cm stat )
554.It Cm svgid
555saved gid from a setgid executable
556.It Cm svuid
557saved UID from a setuid executable
558.It Cm tdev
559control terminal device number
560.It Cm time
561accumulated CPU time, user + system (alias
562.Cm cputime )
563.It Cm tpgid
564control terminal process group ID
565.\".It Cm trss
566.\"text resident set size (in Kbytes)
567.It Cm tsid
568control terminal session ID
569.It Cm tsiz
570text size (in Kbytes)
571.It Cm tt
572control terminal name (two letter abbreviation)
573.It Cm tty
574full name of control terminal
575.It Cm uprocp
576process pointer
577.It Cm ucomm
578name to be used for accounting
579.It Cm uid
580effective user ID
581.It Cm upr
582scheduling priority on return from system call (alias
583.Cm usrpri )
584.It Cm user
585user name (from UID)
586.It Cm vsz
587virtual size in Kbytes (alias
588.Cm vsize )
589.It Cm wchan
590wait channel (as a symbolic name)
591.It Cm xstat
592exit or stop status (valid only for stopped or zombie process)
593.El
594.Sh ENVIRONMENT
595The following environment variables affect the execution of
596.Nm :
597.Bl -tag -width ".Ev COLUMNS"
598.It Ev COLUMNS
599If set, specifies the user's preferred output width in column positions.
600By default,
601.Nm
602attempts to automatically determine the terminal width.
603.El
604.Sh FILES
605.Bl -tag -width ".Pa /boot/kernel/kernel" -compact
606KLD
607.It Pa /boot/kernel/kernel
608default system namelist
609.It Pa /proc
610the mount point of
611.Xr procfs 5
612.El
613.Sh SEE ALSO
614.Xr kill 1 ,
615.Xr pgrep 1 ,
616.Xr pkill 1 ,
617.Xr w 1 ,
618.Xr kvm 3 ,
619.Xr strftime 3 ,
620.Xr mac 4 ,
621.Xr procfs 5 ,
622.Xr pstat 8 ,
623.Xr sysctl 8 ,
624.Xr mutex 9
625.Sh STANDARDS
626For historical reasons,
627.Nm
628utility under
629.Fx
630supports a different set of options from what is described by
631.St -p1003.2 ,
632and what is supported on
633.No non- Ns Bx
634operating systems.
635.Sh HISTORY
636The
637.Nm
638command appeared in
639.At v4 .
640.Sh BUGS
641Since
642.Nm
643cannot run faster than the system and is run as any other scheduled
644process, the information it displays can never be exact.
645.Pp
646The
647.Nm
648utility does not correctly display argument lists containing multibyte
649characters.
650