xref: /netbsd-src/bin/ps/ps.1 (revision ce2c90c7c172d95d2402a5b3d96d8f8e6d138a21)
1.\"	$NetBSD: ps.1,v 1.77 2006/10/09 21:31:29 wiz Exp $
2.\"
3.\" Copyright (c) 1980, 1990, 1991, 1993, 1994
4.\"	The Regents of the University of California.  All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\"    notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\"    notice, this list of conditions and the following disclaimer in the
13.\"    documentation and/or other materials provided with the distribution.
14.\" 3. Neither the name of the University nor the names of its contributors
15.\"    may be used to endorse or promote products derived from this software
16.\"    without specific prior written permission.
17.\"
18.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28.\" SUCH DAMAGE.
29.\"
30.\"     @(#)ps.1	8.3 (Berkeley) 4/18/94
31.\"
32.Dd October 7, 2006
33.Dt PS 1
34.Os
35.Sh NAME
36.Nm ps
37.Nd process status
38.Sh SYNOPSIS
39.Nm
40.Op Fl acCehjlmrsSTuvwx
41.Bk -words
42.Op Fl k Ar key
43.Ek
44.Bk -words
45.Op Fl M Ar core
46.Ek
47.Bk -words
48.Op Fl N Ar system
49.Ek
50.Bk -words
51.Op Fl O Ar fmt
52.Ek
53.Bk -words
54.Op Fl o Ar fmt
55.Ek
56.Bk -words
57.Op Fl p Ar pid
58.Ek
59.Bk -words
60.Op Fl t Ar tty
61.Ek
62.Bk -words
63.Op Fl U Ar username
64.Ek
65.Bk -words
66.Op Fl W Ar swap
67.Ek
68.Nm
69.Op Fl L
70.Sh DESCRIPTION
71.Nm
72displays a header line followed by lines containing information about your
73processes that have controlling terminals.
74The default sort order of controlling terminal and
75(among processes with the same controlling terminal) process
76.Tn ID
77may be changed using the
78.Fl k , Fl m ,
79or
80.Fl r
81options.
82.Pp
83The information displayed is selected based on a set of keywords (see the
84.Fl L
85.Fl O
86and
87.Fl o
88options).
89The default output format includes, for each process, the process'
90.Tn ID ,
91controlling terminal, CPU time (including both user and system time),
92state, and associated command.
93.Pp
94The options are as follows:
95.Bl -tag -width indent
96.It Fl a
97Display information about other users' processes as well as your own.
98.It Fl c
99Do not display full command with arguments, but only the
100executable name.
101This may be somewhat confusing; for example, all
102.Xr sh 1
103scripts will show as
104.Dq sh .
105.It Fl C
106Change the way the CPU percentage is calculated by using a
107.Dq raw
108CPU calculation that ignores
109.Dq resident
110time (this normally has no effect).
111.It Fl e
112Display the environment as well.
113The environment for other
114users' processes can only be displayed by the super-user.
115.It Fl h
116Repeat the information header as often as necessary to guarantee one
117header per page of information.
118.It Fl j
119Print information associated with the following keywords:
120.Ar user , pid , ppid , pgid , sess , jobc , state , tt , time ,
121and
122.Ar command .
123.It Fl k
124Sort the output using the space or comma separated list of keywords.
125Multiple sort keys may be specified, using any of the
126.Fl k , Fl m ,
127or
128.Fl r
129options.
130The default sort order is equivalent to
131.Fl k Ar tdev,pid .
132.It Fl L
133List the set of available keywords.
134.It Fl l
135Display information associated with the following keywords:
136.Ar uid , pid , ppid , cpu , pri , nice , vsz , rss , wchan , state ,
137.Ar tt , time ,
138and
139.Ar command .
140.It Fl M
141Extract values from the specified core file instead of the running system.
142.It Fl m
143Sort by memory usage,
144equivalent to
145.Fl k Ar vsz .
146.It Fl N
147Extract the name list from the specified system instead of the default
148.Dq Pa /netbsd .
149Ignored unless
150.Fl M
151is specified.
152.It Fl O
153Display information associated with the space or comma separated list
154of keywords specified.
155The
156.Fl O
157option does not suppress the default display;
158it inserts additional keywords just after the
159.Ar pid
160keyword in the default display, or after the
161.Ar pid
162keyword (if any) in a non-default display specified before the
163first use of the
164.Fl O
165flag.
166Keywords inserted by multiple
167.Fl O
168options will be adjacent.
169.Pp
170An equals sign
171.Pq Dq \&=
172followed by a customised header string may be appended to a keyword,
173as described in more detail under the
174.Fl o
175option.
176.It Fl o
177Display information associated with the space or comma separated list
178of keywords specified.
179Use of the
180.Fl o
181option suppresses the set of keywords that would be displayed by default,
182or appends to the set of keywords specified by other options.
183.Pp
184An equals sign
185.Pq Dq \&=
186followed by a customised header string may be appended to a keyword.
187This causes the printed header to use the specified string instead of
188the default header associated with the keyword.
189.Pp
190Everything after the first equals sign is part of the customised
191header text, and this may include embedded spaces
192.Pq Dq " " ,
193commas
194.Pq Dq \&, ,
195or equals signs
196.Pq Dq \&= .
197To specify multiple keywords with customised headers, use multiple
198.Fl o
199or
200.Fl O
201options.
202.Pp
203If all the keywords to be displayed have customised headers,
204and all the customised headers are entirely empty,
205then the header line is not printed at all.
206.It Fl p
207Display information associated with the specified process
208.Tn ID .
209.It Fl r
210Sort by current CPU usage.
211This is equivalent to
212.Fl k Ar %cpu .
213.It Fl S
214Change the way the process time is calculated by summing all exited
215children to their parent process.
216.It Fl s
217Display one line for each LWP, rather than one line for each process,
218and display information associated with the following keywords:
219.Ar uid , pid , ppid , cpu , lid , nlwp , pri , nice , vsz , rss ,
220.Ar wchan , lstate , tt , time ,
221and
222.Ar command .
223.It Fl T
224Display information about processes attached to the device associated
225with the standard input.
226.It Fl t
227Display information about processes attached to the specified terminal
228device.
229Use an question mark
230.Pq Dq \&?
231for processes not attached to a
232terminal device and a minus sign
233.Pq Dq -
234for processes that have
235been revoked from their terminal device.
236.It Fl U
237Displays processes belonging to the user whose username or uid has
238been given to the
239.Fl U
240switch.
241.It Fl u
242Display information associated with the following keywords:
243.Ar user , pid , %cpu , %mem , vsz , rss , tt , state , start , time ,
244and
245.Ar command .
246The
247.Fl u
248option implies the
249.Fl r
250option.
251.It Fl v
252Display information associated with the following keywords:
253.Ar pid , state , time , sl , re , pagein , vsz , rss , lim , tsiz ,
254.Ar %cpu , %mem ,
255and
256.Ar command .
257The
258.Fl v
259option implies the
260.Fl m
261option.
262.It Fl W
263Extract swap information from the specified file instead of the
264default
265.Dq Pa /dev/drum .
266Ignored unless
267.Fl M
268is specified.
269.It Fl w
270Use 132 columns to display information, instead of the default which
271is your window size.
272If the
273.Fl w
274option is specified more than once,
275.Nm
276will use as many columns as necessary without regard for your window size.
277.It Fl x
278Also display information about processes without controlling terminals.
279.El
280.Pp
281A complete list of the available keywords are listed below.
282Some of these keywords are further specified as follows:
283.Bl -tag -width indent
284.It Ar %cpu
285The CPU utilization of the process; this is a decaying average over up to
286a minute of previous (real) time.
287Since the time base over which this is computed varies (since processes may
288be very young) it is possible for the sum of all
289.Tn %CPU
290fields to exceed 100%.
291.It Ar %mem
292The percentage of real memory used by this process.
293.It Ar flags
294The flags (in hexadecimal) associated with the process as in
295the include file
296.Aq Pa sys/proc.h :
297.Bl -column P_NOCLDSTOP P_NOCLDSTOP
298.It Dv "P_ADVLOCK" Ta No "0x00000001	process may hold a POSIX advisory lock"
299.It Dv "P_CONTROLT" Ta No "0x00000002	process has a controlling terminal"
300.It Dv "P_INMEM" Ta No "0x00000004	process is loaded into memory"
301.It Dv "P_NOCLDSTOP" Ta No "0x00000008	no
302.Dv SIGCHLD
303when children stop
304.It Dv "P_PPWAIT" Ta No "0x00000010	parent is waiting for child to exec/exit"
305.It Dv "P_PROFIL" Ta No "0x00000020	process has started profiling"
306.It Dv "P_SELECT" Ta No "0x00000040	selecting; wakeup/waiting danger"
307.It Dv "P_SINTR" Ta No "0x00000080	sleep is interruptible"
308.It Dv "P_SUGID" Ta No "0x00000100	process had set id privileges since last exec"
309.It Dv "P_SYSTEM" Ta No "0x00000200	system process: no sigs, stats or swapping"
310.It Dv "P_TIMEOUT" Ta No "0x00000400	timing out during sleep"
311.It Dv "P_TRACED" Ta No "0x00000800	process is being traced"
312.It Dv "P_WAITED" Ta No "0x00001000	debugging process has waited for child"
313.It Dv "P_WEXIT" Ta No "0x00002000	working on exiting"
314.It Dv "P_EXEC" Ta No "0x00004000	process called"
315.Xr execve 2
316.It Dv "P_OWEUPC" Ta No "0x00008000	owe process an addupc() call at next ast"
317.\" the routine addupc is not documented in the man pages
318.It Dv "P_FSTRACE" Ta No "0x00010000	tracing via file system"
319.It Dv "P_NOCLDWAIT" Ta No "0x00020000	no zombies when children die"
320.It Dv "P_32" Ta No "0x00040000	32-bit process (used on 64-bit kernels)"
321.It Dv "P_BIGLOCK" Ta No "0x00080000	process needs kernel ``big lock'' to run"
322.It Dv "P_INEXEC" Ta No "0x00100000	process is exec'ing and cannot be traced"
323.It Dv "P_SYSTRACE" Ta No "0x00200000	process system call tracing active"
324.El
325.It Ar lim
326The soft limit on memory used, specified via a call to
327.Xr setrlimit 2 .
328.It Ar lstart
329The exact time the command started, using the
330.Dq %C
331format described in
332.Xr strftime 3 .
333.It Ar nice
334The process scheduling increment (see
335.Xr setpriority 2 ) .
336.It Ar rss
337the real memory (resident set) size of the process (in 1024 byte units).
338.It Ar start
339The time the command started.
340If the command started less than 24 hours ago, the start time is
341displayed using the
342.Dq %l:%M%p
343format described in
344.Xr strftime 3 .
345If the command started less than 7 days ago, the start time is
346displayed using the
347.Dq %a%p
348format.
349Otherwise, the start time is displayed using the
350.Dq %e%b%y
351format.
352.It Ar state
353The state is given by a sequence of letters, for example,
354.Dq Tn RWNA .
355The first letter indicates the run state of the process:
356.Pp
357.Bl -tag -width indent -compact
358.It D
359Marks a process in disk (or other short term, uninterruptible) wait.
360.It I
361Marks a process that is idle (sleeping for longer than about 20 seconds).
362.It R
363Marks a runnable process.
364.It S
365Marks a process that is sleeping for less than about 20 seconds.
366.It T
367Marks a stopped process.
368.It U
369Marks a suspended process.
370.It Z
371Marks a dead process (a
372.Dq zombie ) .
373.El
374.Pp
375Additional characters after these, if any, indicate additional state
376information:
377.Pp
378.Bl -tag -width indent -compact
379.It +
380The process is in the foreground process group of its control terminal.
381.It -
382The LWP is detached (can't be waited for).
383.It \*[Lt]
384The process has raised
385.Tn CPU
386scheduling priority.
387.It \*[Gt]
388The process has specified a soft limit on memory requirements and is
389currently exceeding that limit; such a process is (necessarily) not
390swapped.
391.It A
392the process has asked for random page replacement
393.Pf ( Dv VA_ANOM ,
394from
395.Xr madvise 2 ,
396for example, a LISP interpreter in a garbage collect).
397.It a
398The process is using scheduler activations.
399.It E
400The process is trying to exit.
401.It K
402The process is a kernel thread or system process.
403.It L
404The process has pages locked in core (for example, for raw
405.Tn I/O ) .
406.It l
407The process has multiple LWPs.
408.It N
409The process has reduced
410.Tn CPU
411scheduling priority (see
412.Xr setpriority 2 ) .
413.It S
414The process has asked for
415.Tn FIFO
416page replacement
417.Pf ( Dv VA_SEQL ,
418from
419.Xr madvise 2 ,
420for example, a large image processing program using virtual memory to
421sequentially address voluminous data).
422.It s
423The process is a session leader.
424.It V
425The process is suspended during a
426.Xr vfork 2 .
427.It W
428The process is swapped out.
429.It X
430The process is being traced or debugged.
431.It x
432The process is running under
433.Xr systrace 1 .
434.El
435.It Ar tt
436An abbreviation for the pathname of the controlling terminal, if any.
437The abbreviation consists of the two letters following
438.Dq Pa /dev/tty ,
439or, for the console,
440.Dq co .
441This is followed by a
442.Dq \&-
443if the process can no longer reach that
444controlling terminal (i.e., it has been revoked).
445.It Ar wchan
446The event (an address in the system) on which a process waits.
447When printed numerically, the initial part of the address is
448trimmed off and the result is printed in hex, for example, 0x80324000 prints
449as 324000.
450.El
451.Pp
452When printing using the
453.Ar command
454keyword, a process that has exited and has a parent that has not yet
455waited for the process (in other words, a zombie) is listed as
456.Dq Aq defunct ,
457and a process which is blocked while trying to exit is listed as
458.Dq Aq exiting .
459.Pp
460.Nm
461will try to locate the processes' argument vector from the user
462area in order to print the command name and arguments.
463This method is not reliable because a process is allowed to destroy this
464information.
465The
466.Ar ucomm
467(accounting) keyword will always contain the real command name as
468contained in the process structure's
469.Va p_comm
470field.
471.Pp
472If the command vector cannot be located (usually because it has not
473been set, as is the case of system processes and/or kernel threads)
474the command name is printed within square brackets.
475.Pp
476To indicate that the argument vector has been tampered with,
477.Nm
478will append the real command name to the output within parentheses
479if the basename of the first argument in the argument vector
480does not match the contents of the real command name.
481.Pp
482In addition,
483.Nm
484checks for the following two situations and does not append the
485real command name parenthesized:
486.Bl -tag -width indent
487.It -shellname
488The login process traditionally adds a
489.Sq -
490in front of the shell name to indicate a login shell.
491.Nm
492will not append parenthesized the command name if it matches with
493the name in the first argument of the argument vector, skipping
494the leading
495.Sq - .
496.It daemonname: current-activity
497Daemon processes frequently report their current activity by setting
498their name to be like
499.Dq daemonname: current-activity .
500.Nm
501will not append parenthesized the command name, if the string preceding the
502.Sq \&:
503in the first argument of the argument vector matches the command name.
504.El
505.Sh KEYWORDS
506The following is a complete list of the available keywords and their
507meanings.
508Several of them have aliases (keywords which are synonyms).
509.Pp
510.Bl -tag -width groupnames -compact
511.It Ar %cpu
512percentage CPU usage (alias
513.Ar pcpu )
514.It Ar %mem
515percentage memory usage (alias
516.Ar pmem )
517.It Ar acflag
518accounting flag (alias
519.Ar acflg )
520.It Ar comm
521command (the argv[0] value)
522.It Ar command
523command and arguments (alias
524.Ar args )
525.It Ar cpu
526short-term CPU usage factor (for scheduling)
527.It Ar ctime
528accumulated CPU time of all children that have exited
529.It Ar egid
530effective group id
531.It Ar egroup
532group name (from egid)
533.It Ar etime
534elapsed time since the process was started, in the form
535.Li [[dd-]hh:]mm:ss
536.It Ar euid
537effective user id
538.It Ar euser
539user name (from euid)
540.It Ar flags
541the process flags, in hexadecimal (alias
542.Ar f )
543.It Ar gid
544effective group id
545.It Ar group
546group name (from gid)
547.It Ar groups
548group access list
549.It Ar groupnames
550group names (from group access list)
551.It Ar holdcnt
552number of holds on the process (if non-zero, process can't be swapped)
553.It Ar inblk
554total blocks read (alias
555.Ar inblock )
556.It Ar jobc
557job control count
558.It Ar ktrace
559tracing flags
560.It Ar ktracep
561tracing vnode
562.It Ar laddr
563kernel virtual address of the
564.Tn "struct lwp"
565belonging to the LWP.
566.It Ar lid
567ID of the LWP
568.It Ar lim
569memory use limit
570.It Ar logname
571login name of user who started the process (alias
572.Ar login )
573.It Ar lstart
574time started
575.It Ar lstate
576symbolic LWP state
577.It Ar majflt
578total page faults
579.It Ar minflt
580total page reclaims
581.It Ar msgrcv
582total messages received (reads from pipes/sockets)
583.It Ar msgsnd
584total messages sent (writes on pipes/sockets)
585.It Ar nice
586nice value (alias
587.Ar ni )
588.It Ar nivcsw
589total involuntary context switches
590.It Ar nlwp
591number of LWPs in the process
592.It Ar nsigs
593total signals taken (alias
594.Ar nsignals )
595.It Ar nswap
596total swaps in/out
597.It Ar nvcsw
598total voluntary context switches
599.It Ar nwchan
600wait channel (as an address)
601.It Ar oublk
602total blocks written (alias
603.Ar oublock )
604.It Ar p_ru
605resource usage pointer (valid only for zombie)
606.It Ar paddr
607kernel virtual address of the
608.Tn "struct proc"
609belonging to the process.
610.It Ar pagein
611pageins (same as majflt)
612.It Ar pgid
613process group number
614.It Ar pid
615process
616.Tn ID
617.It Ar ppid
618parent process
619.Tn ID
620.It Ar pri
621scheduling priority
622.It Ar re
623core residency time (in seconds; 127 = infinity)
624.It Ar rgid
625real group
626.Tn ID
627.It Ar rlink
628reverse link on run queue, or 0
629.It Ar rlwp
630Number of LWPs on a processor or run queue
631.It Ar rss
632resident set size
633.It Ar rsz
634resident set size + (text size / text use count) (alias
635.Ar rssize )
636.It Ar ruid
637real user
638.Tn ID
639.It Ar ruser
640user name (from ruid)
641.It Ar sess
642session pointer
643.It Ar sid
644session
645.Tn ID
646.It Ar sig
647pending signals (alias
648.Ar pending )
649.It Ar sigcatch
650caught signals (alias
651.Ar caught )
652.It Ar sigignore
653ignored signals (alias
654.Ar ignored )
655.It Ar sigmask
656blocked signals (alias
657.Ar blocked )
658.It Ar sl
659sleep time (in seconds; 127 = infinity)
660.It Ar start
661time started
662.It Ar state
663symbolic process state (alias
664.Ar stat )
665.It Ar stime
666accumulated system CPU time
667.It Ar svgid
668saved gid from a setgid executable
669.It Ar svgroup
670group name (from svgid)
671.It Ar svuid
672saved uid from a setuid executable
673.It Ar svuser
674user name (from svuid)
675.It Ar tdev
676control terminal device number
677.It Ar time
678accumulated CPU time, user + system (alias
679.Ar cputime )
680.It Ar tpgid
681control terminal process group
682.Tn ID
683.It Ar tsess
684control terminal session pointer
685.It Ar tsiz
686text size (in Kbytes)
687.It Ar tt
688control terminal name (two letter abbreviation)
689.It Ar tty
690full name of control terminal
691.It Ar uaddr
692kernel virtual address of the
693.Tn "struct user"
694belonging to the LWP.
695.It Ar ucomm
696name to be used for accounting
697.It Ar uid
698effective user
699.Tn ID
700.It Ar upr
701scheduling priority on return from system call (alias
702.Ar usrpri )
703.It Ar user
704user name (from uid)
705.It Ar utime
706accumulated user CPU time
707.It Ar vsz
708virtual size in Kbytes (alias
709.Ar vsize )
710.It Ar wchan
711wait channel (as a symbolic name)
712.It Ar xstat
713exit or stop status (valid only for stopped or zombie process)
714.El
715.Sh FILES
716.Bl -tag -width /var/run/kvm.db -compact
717.It Pa /dev
718special files and device names
719.It Pa /dev/drum
720default swap device
721.It Pa /var/run/dev.db
722/dev name database
723.It Pa /var/db/kvm.db
724system namelist database
725.It Pa /netbsd
726default system namelist
727.El
728.Sh SEE ALSO
729.Xr kill 1 ,
730.Xr pgrep 1 ,
731.Xr pkill 1 ,
732.Xr sh 1 ,
733.Xr systrace 1 ,
734.Xr w 1 ,
735.Xr kvm 3 ,
736.Xr strftime 3 ,
737.Xr dev_mkdb 8 ,
738.Xr pstat 8
739.Sh BUGS
740Since
741.Nm
742cannot run faster than the system and is run as any other scheduled
743process, the information it displays can never be exact.
744