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