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