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 27, 2004 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 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. 190If all keywords have empty header texts, no header line is written. 191.It Fl p 192Display information about processes which match the specified process IDs. 193.It Fl r 194Sort by current CPU usage, instead of the combination of controlling 195terminal and process ID. 196.It Fl S 197Change the way the process time is calculated by summing all exited 198children to their parent process. 199.It Fl T 200Display information about processes attached to the device associated 201with the standard input. 202.It Fl t 203Display information about processes attached to the specified terminal 204devices. 205.It Fl U 206Display the processes belonging to the specified usernames. 207.It Fl u 208Display information associated with the following keywords: 209.Cm user , pid , %cpu , %mem , vsz , rss , tt , state , start , time , 210and 211.Cm command . 212The 213.Fl u 214option implies the 215.Fl r 216option. 217.It Fl v 218Display information associated with the following keywords: 219.Cm pid , state , time , sl , re , pagein , vsz , rss , lim , tsiz , 220.Cm %cpu , %mem , 221and 222.Cm command . 223The 224.Fl v 225option implies the 226.Fl m 227option. 228.It Fl w 229Use 132 columns to display information, instead of the default which 230is your window size. 231If the 232.Fl w 233option is specified more than once, 234.Nm 235will use as many columns as necessary without regard for your window size. 236.It Fl X 237When displaying processes matched by other options, skip any processes 238which do not have a controlling terminal. 239.It Fl x 240When displaying processes matched by other options, include processes 241which do not have a controlling terminal. 242This is the opposite of the 243.Fl X 244option. 245If both 246.Fl X 247and 248.Fl x 249are specified in the same command, then 250.Nm 251will use the one which was specified last. 252.It Fl Z 253Add 254.Xr mac 4 255label to the list of keywords for which 256.Nm 257will display information. 258.El 259.Pp 260A complete list of the available keywords are listed below. 261Some of these keywords are further specified as follows: 262.Bl -tag -width lockname 263.It Cm %cpu 264The CPU utilization of the process; this is a decaying average over up to 265a minute of previous (real) time. 266Since the time base over which this is computed varies (since processes may 267be very young) it is possible for the sum of all 268.Cm %cpu 269fields to exceed 100%. 270.It Cm %mem 271The percentage of real memory used by this process. 272.It Cm flags 273The flags associated with the process as in 274the 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 302The MAC label of the process. 303.It Cm lim 304The soft limit on memory used, specified via a call to 305.Xr setrlimit 2 . 306.It Cm lstart 307The exact time the command started, using the 308.Ql %c 309format described in 310.Xr strftime 3 . 311.It Cm lockname 312The name of the lock that the process is currently blocked on. 313If the name is invalid or unknown, then 314.Dq ???\& 315is displayed. 316.It Cm logname 317The login name associated with the session the process is in (see 318.Xr getlogin 2 ) . 319.It Cm mwchan 320The event name if the process is blocked normally, or the lock name if 321the process is blocked on a lock. 322See the wchan and lockname keywords 323for details. 324.It Cm nice 325The process scheduling increment (see 326.Xr setpriority 2 ) . 327.It Cm rss 328the real memory (resident set) size of the process (in 1024 byte units). 329.It Cm start 330The time the command started. 331If the command started less than 24 hours ago, the start time is 332displayed using the 333.Dq Li %l:ps.1p 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 Li %a6.15p 339format. 340Otherwise, the start time is displayed using the 341.Dq Li %e%b%y 342format. 343.It Cm state 344The state is given by a sequence of characters, for example, 345.Dq Li RWNA . 346The first character indicates the run state of the process: 347.Pp 348.Bl -tag -width indent -compact 349.It Li D 350Marks a process in disk (or other short term, uninterruptible) wait. 351.It Li I 352Marks a process that is idle (sleeping for longer than about 20 seconds). 353.It Li L 354Marks a process that is waiting to acquire a lock. 355.It Li R 356Marks a runnable process. 357.It Li S 358Marks a process that is sleeping for less than about 20 seconds. 359.It Li T 360Marks a stopped process. 361.It Li W 362Marks an idle interrupt thread. 363.It Li 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 Li + 373The process is in the foreground process group of its control terminal. 374.It Li < 375The process has raised CPU scheduling priority. 376.It Li E 377The process is trying to exit. 378.It Li J 379Marks a process which is in 380.Xr jail 2 . 381The hostname of the prison can be found in 382.Pa /proc/ Ns Ao Ar pid Ac Ns Pa /status . 383.It Li L 384The process has pages locked in core (for example, for raw 385.Tn I/O ) . 386.It Li N 387The process has reduced CPU scheduling priority (see 388.Xr setpriority 2 ) . 389.It Li s 390The process is a session leader. 391.It Li V 392The process is suspended during a 393.Xr vfork 2 . 394.It Li W 395The process is swapped out. 396.It Li X 397The process is being traced or debugged. 398.El 399.It Cm tt 400An abbreviation for the pathname of the controlling terminal, if any. 401The abbreviation consists of the three letters following 402.Pa /dev/tty , 403or, for the console, 404.Dq Li con . 405This is followed by a 406.Ql - 407if the process can no longer reach that 408controlling terminal (i.e., it has been revoked). 409.It Cm wchan 410The event (an address in the system) on which a process waits. 411When printed numerically, the initial part of the address is 412trimmed off and the result is printed in hex, for example, 0x80324000 prints 413as 324000. 414.El 415.Pp 416When printing using the command keyword, a process that has exited and 417has a parent that has not yet waited for the process (in other words, a zombie) 418is listed as 419.Dq Li <defunct> , 420and a process which is blocked while trying 421to exit is listed as 422.Dq Li <exiting> . 423If the arguments cannot be located (usually because it has not been set, as is 424the case of system processes and/or kernel threads) the command name is printed 425within square brackets. 426The 427.Nm 428utility first tries to obtain the arguments cached by the kernel (if they were 429shorter than the value of the 430.Va kern.ps_arg_cache_limit 431sysctl). 432The process can change the arguments shown with 433.Xr setproctitle 3 . 434Otherwise, 435.Nm 436makes an educated guess as to the file name and arguments given when the 437process was created by examining memory or the swap area. 438The method is inherently somewhat unreliable and in any event a process 439is entitled to destroy this information. 440The ucomm (accounting) keyword can, however, be depended on. 441If the arguments are unavailable or do not agree with the ucomm keyword, 442the value for the ucomm keyword is appended to the arguments in parentheses. 443.Sh KEYWORDS 444The following is a complete list of the available keywords and their 445meanings. 446Several of them have aliases (keywords which are synonyms). 447.Pp 448.Bl -tag -width ".Cm sigignore" -compact 449.It Cm %cpu 450percentage CPU usage (alias 451.Cm pcpu ) 452.It Cm %mem 453percentage memory usage (alias 454.Cm pmem ) 455.It Cm acflag 456accounting flag (alias 457.Cm acflg ) 458.It Cm args 459command and arguments 460.It Cm comm 461command 462.It Cm command 463command and arguments 464.It Cm cpu 465short-term CPU usage factor (for scheduling) 466.It Cm etime 467elapsed running time 468.It Cm flags 469the process flags, in hexadecimal (alias 470.Cm f ) 471.It Cm inblk 472total blocks read (alias 473.Cm inblock ) 474.It Cm jobc 475job control count 476.It Cm ktrace 477tracing flags 478.It Cm label 479MAC label 480.It Cm lim 481memoryuse limit 482.It Cm lockname 483lock currently blocked on (as a symbolic name) 484.It Cm logname 485login name of user who started the session 486.It Cm lstart 487time started 488.It Cm majflt 489total page faults 490.It Cm minflt 491total page reclaims 492.It Cm msgrcv 493total messages received (reads from pipes/sockets) 494.It Cm msgsnd 495total messages sent (writes on pipes/sockets) 496.It Cm mwchan 497wait channel or lock currently blocked on 498.It Cm nice 499nice value (alias 500.Cm ni ) 501.It Cm nivcsw 502total involuntary context switches 503.It Cm nsigs 504total signals taken (alias 505.Cm nsignals ) 506.It Cm nswap 507total swaps in/out 508.It Cm nvcsw 509total voluntary context switches 510.It Cm nwchan 511wait channel (as an address) 512.It Cm oublk 513total blocks written (alias 514.Cm oublock ) 515.It Cm paddr 516swap address 517.It Cm pagein 518pageins (same as majflt) 519.It Cm pgid 520process group number 521.It Cm pid 522process ID 523.It Cm poip 524pageouts in progress 525.It Cm ppid 526parent process ID 527.It Cm pri 528scheduling priority 529.It Cm re 530core residency time (in seconds; 127 = infinity) 531.It Cm rgid 532real group ID 533.It Cm rgroup 534group name (from rgid) 535.It Cm rlink 536reverse link on run queue, or 0 537.It Cm rss 538resident set size 539.It Cm rtprio 540realtime priority (101 = not a realtime process) 541.It Cm ruid 542real user ID 543.It Cm ruser 544user name (from ruid) 545.It Cm sid 546session ID 547.It Cm sig 548pending signals (alias 549.Cm pending ) 550.It Cm sigcatch 551caught signals (alias 552.Cm caught ) 553.It Cm sigignore 554ignored signals (alias 555.Cm ignored ) 556.It Cm sigmask 557blocked signals (alias 558.Cm blocked ) 559.It Cm sl 560sleep time (in seconds; 127 = infinity) 561.It Cm start 562time started 563.It Cm state 564symbolic process state (alias 565.Cm stat ) 566.It Cm svgid 567saved gid from a setgid executable 568.It Cm svuid 569saved UID from a setuid executable 570.It Cm tdev 571control terminal device number 572.It Cm time 573accumulated CPU time, user + system (alias 574.Cm cputime ) 575.It Cm tpgid 576control terminal process group ID 577.\".It Cm trss 578.\"text resident set size (in Kbytes) 579.It Cm tsid 580control terminal session ID 581.It Cm tsiz 582text size (in Kbytes) 583.It Cm tt 584control terminal name (two letter abbreviation) 585.It Cm tty 586full name of control terminal 587.It Cm uprocp 588process pointer 589.It Cm ucomm 590name to be used for accounting 591.It Cm uid 592effective user ID 593.It Cm upr 594scheduling priority on return from system call (alias 595.Cm usrpri ) 596.It Cm user 597user name (from UID) 598.It Cm vsz 599virtual size in Kbytes (alias 600.Cm vsize ) 601.It Cm wchan 602wait channel (as a symbolic name) 603.It Cm xstat 604exit or stop status (valid only for stopped or zombie process) 605.El 606.Sh ENVIRONMENT 607The following environment variables affect the execution of 608.Nm : 609.Bl -tag -width ".Ev COLUMNS" 610.It Ev COLUMNS 611If set, specifies the user's preferred output width in column positions. 612By default, 613.Nm 614attempts to automatically determine the terminal width. 615.El 616.Sh FILES 617.Bl -tag -width ".Pa /boot/kernel/kernel" -compact 618.It Pa /boot/kernel/kernel 619default system namelist 620.It Pa /proc 621the mount point of 622.Xr procfs 5 623.El 624.Sh SEE ALSO 625.Xr kill 1 , 626.Xr pgrep 1 , 627.Xr pkill 1 , 628.Xr w 1 , 629.Xr kvm 3 , 630.Xr strftime 3 , 631.Xr mac 4 , 632.Xr procfs 5 , 633.Xr pstat 8 , 634.Xr sysctl 8 , 635.Xr mutex 9 636.Sh STANDARDS 637For historical reasons, the 638.Nm 639utility under 640.Fx 641supports a different set of options from what is described by 642.St -p1003.2 , 643and what is supported on 644.No non- Ns Bx 645operating systems. 646.Sh HISTORY 647The 648.Nm 649command appeared in 650.At v4 . 651.Sh BUGS 652Since 653.Nm 654cannot run faster than the system and is run as any other scheduled 655process, the information it displays can never be exact. 656.Pp 657The 658.Nm 659utility does not correctly display argument lists containing multibyte 660characters. 661