xref: /netbsd-src/bin/ps/ps.1 (revision 8b0f9554ff8762542c4defc4f70e1eb76fb508fa)
1.\"	$NetBSD: ps.1,v 1.80 2007/09/09 10:35:32 apb 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 September 9, 2007
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 a
388The process is using scheduler activations.
389.It E
390The process is trying to exit.
391.It K
392The process is a kernel thread or system process.
393.It L
394The process has pages locked in core (for example, for raw
395.Tn I/O ) .
396.It l
397The process has multiple LWPs.
398.It N
399The process has reduced
400.Tn CPU
401scheduling priority (see
402.Xr setpriority 2 ) .
403.It s
404The process is a session leader.
405.It V
406The process is suspended during a
407.Xr vfork 2 .
408.It W
409The process is swapped out.
410.It X
411The process is being traced or debugged.
412.It x
413The process is running under
414.Xr systrace 1 .
415.El
416.It Ar tt
417An abbreviation for the pathname of the controlling terminal, if any.
418The abbreviation consists of the two letters following
419.Dq Pa /dev/tty ,
420or, for the console,
421.Dq co .
422This is followed by a
423.Dq \&-
424if the process can no longer reach that
425controlling terminal (i.e., it has been revoked).
426.It Ar wchan
427The event (an address in the system) on which a process waits.
428When printed numerically, the initial part of the address is
429trimmed off and the result is printed in hex, for example, 0x80324000 prints
430as 324000.
431.El
432.Pp
433When printing using the
434.Ar command
435keyword, a process that has exited and has a parent that has not yet
436waited for the process (in other words, a zombie) is listed as
437.Dq Aq defunct ,
438and a process which is blocked while trying to exit is listed as
439.Dq Aq exiting .
440.Pp
441.Nm
442will try to locate the processes' argument vector from the user
443area in order to print the command name and arguments.
444This method is not reliable because a process is allowed to destroy this
445information.
446The
447.Ar ucomm
448(accounting) keyword will always contain the real command name as
449contained in the process structure's
450.Va p_comm
451field.
452.Pp
453If the command vector cannot be located (usually because it has not
454been set, as is the case of system processes and/or kernel threads)
455the command name is printed within square brackets.
456.Pp
457To indicate that the argument vector has been tampered with,
458.Nm
459will append the real command name to the output within parentheses
460if the basename of the first argument in the argument vector
461does not match the contents of the real command name.
462.Pp
463In addition,
464.Nm
465checks for the following two situations and does not append the
466real command name parenthesized:
467.Bl -tag -width indent
468.It -shellname
469The login process traditionally adds a
470.Sq -
471in front of the shell name to indicate a login shell.
472.Nm
473will not append parenthesized the command name if it matches with
474the name in the first argument of the argument vector, skipping
475the leading
476.Sq - .
477.It daemonname: current-activity
478Daemon processes frequently report their current activity by setting
479their name to be like
480.Dq daemonname: current-activity .
481.Nm
482will not append parenthesized the command name, if the string preceding the
483.Sq \&:
484in the first argument of the argument vector matches the command name.
485.El
486.Sh KEYWORDS
487The following is a complete list of the available keywords and their
488meanings.
489Several of them have aliases (keywords which are synonyms).
490.Pp
491.Bl -tag -width groupnames -compact
492.It Ar %cpu
493percentage CPU usage (alias
494.Ar pcpu )
495.It Ar %mem
496percentage memory usage (alias
497.Ar pmem )
498.It Ar acflag
499accounting flag (alias
500.Ar acflg )
501.It Ar comm
502command (the argv[0] value)
503.It Ar command
504command and arguments (alias
505.Ar args )
506.It Ar cpu
507short-term CPU usage factor (for scheduling)
508.It Ar ctime
509accumulated CPU time of all children that have exited
510.It Ar egid
511effective group id
512.It Ar egroup
513group name (from egid)
514.It Ar emul
515emulation name
516.It Ar etime
517elapsed time since the process was started, in the form
518.Li [[dd-]hh:]mm:ss
519.It Ar euid
520effective user id
521.It Ar euser
522user name (from euid)
523.It Ar flags
524the process flags, in hexadecimal (alias
525.Ar f )
526.It Ar gid
527effective group id
528.It Ar group
529group name (from gid)
530.It Ar groupnames
531group names (from group access list)
532.It Ar groups
533group access list
534.It Ar holdcnt
535number of holds on the process (if non-zero, process can't be swapped)
536.It Ar inblk
537total blocks read (alias
538.Ar inblock )
539.It Ar jobc
540job control count
541.It Ar ktrace
542tracing flags
543.It Ar ktracep
544tracing vnode
545.It Ar laddr
546kernel virtual address of the
547.Tn "struct lwp"
548belonging to the LWP.
549.It Ar lid
550ID of the LWP
551.It Ar lim
552memory use limit
553.It Ar lname
554descriptive name of the LWP
555.It Ar logname
556login name of user who started the process (alias
557.Ar login )
558.It Ar lstart
559time started
560.It Ar lstate
561symbolic LWP state
562.It Ar majflt
563total page faults
564.It Ar minflt
565total page reclaims
566.It Ar msgrcv
567total messages received (reads from pipes/sockets)
568.It Ar msgsnd
569total messages sent (writes on pipes/sockets)
570.It Ar nice
571nice value (alias
572.Ar ni )
573.It Ar nivcsw
574total involuntary context switches
575.It Ar nlwp
576number of LWPs in the process
577.It Ar nsigs
578total signals taken (alias
579.Ar nsignals )
580.It Ar nswap
581total swaps in/out
582.It Ar nvcsw
583total voluntary context switches
584.It Ar nwchan
585wait channel (as an address)
586.It Ar oublk
587total blocks written (alias
588.Ar oublock )
589.It Ar p_ru
590resource usage pointer (valid only for zombie)
591.It Ar paddr
592kernel virtual address of the
593.Tn "struct proc"
594belonging to the process.
595.It Ar pagein
596pageins (same as majflt)
597.It Ar pgid
598process group number
599.It Ar pid
600process
601.Tn ID
602.It Ar ppid
603parent process
604.Tn ID
605.It Ar pri
606scheduling priority
607.It Ar re
608core residency time (in seconds; 127 = infinity)
609.It Ar rgid
610real group
611.Tn ID
612.It Ar rlink
613reverse link on run queue, or 0
614.It Ar rlwp
615Number of LWPs on a processor or run queue
616.It Ar rss
617resident set size
618.It Ar rsz
619resident set size + (text size / text use count) (alias
620.Ar rssize )
621.It Ar ruid
622real user
623.Tn ID
624.It Ar ruser
625user name (from ruid)
626.It Ar sess
627session pointer
628.It Ar sid
629session
630.Tn ID
631.It Ar sig
632pending signals (alias
633.Ar pending )
634.It Ar sigcatch
635caught signals (alias
636.Ar caught )
637.It Ar sigignore
638ignored signals (alias
639.Ar ignored )
640.It Ar sigmask
641blocked signals (alias
642.Ar blocked )
643.It Ar sl
644sleep time (in seconds; 127 = infinity)
645.It Ar start
646time started
647.It Ar state
648symbolic process state (alias
649.Ar stat )
650.It Ar stime
651accumulated system CPU time
652.It Ar svgid
653saved gid from a setgid executable
654.It Ar svgroup
655group name (from svgid)
656.It Ar svuid
657saved uid from a setuid executable
658.It Ar svuser
659user name (from svuid)
660.It Ar tdev
661control terminal device number
662.It Ar time
663accumulated CPU time, user + system (alias
664.Ar cputime )
665.It Ar tpgid
666control terminal process group
667.Tn ID
668.It Ar tsess
669control terminal session pointer
670.It Ar tsiz
671text size (in Kbytes)
672.It Ar tt
673control terminal name (two letter abbreviation)
674.It Ar tty
675full name of control terminal
676.It Ar uaddr
677kernel virtual address of the
678.Tn "struct user"
679belonging to the LWP.
680.It Ar ucomm
681name to be used for accounting
682.It Ar uid
683effective user
684.Tn ID
685.It Ar upr
686scheduling priority on return from system call (alias
687.Ar usrpri )
688.It Ar user
689user name (from uid)
690.It Ar utime
691accumulated user CPU time
692.It Ar vsz
693virtual size in Kbytes (alias
694.Ar vsize )
695.It Ar wchan
696wait channel (as a symbolic name)
697.It Ar xstat
698exit or stop status (valid only for stopped or zombie process)
699.El
700.Sh FILES
701.Bl -tag -width /var/run/kvm.db -compact
702.It Pa /dev
703special files and device names
704.It Pa /dev/drum
705default swap device
706.It Pa /var/run/dev.db
707/dev name database
708.It Pa /var/db/kvm.db
709system namelist database
710.It Pa /netbsd
711default system namelist
712.El
713.Sh SEE ALSO
714.Xr kill 1 ,
715.Xr pgrep 1 ,
716.Xr pkill 1 ,
717.Xr sh 1 ,
718.Xr systrace 1 ,
719.Xr w 1 ,
720.Xr kvm 3 ,
721.Xr strftime 3 ,
722.Xr dev_mkdb 8 ,
723.Xr pstat 8
724.Sh BUGS
725Since
726.Nm
727cannot run faster than the system and is run as any other scheduled
728process, the information it displays can never be exact.
729