1.\" $NetBSD: ps.1,v 1.93 2010/05/14 17:37:06 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 22, 2009 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.In 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_NOCLDSTOP" Ta No "0x00000008 no" Dv SIGCHLD No when children stop 292.It Dv "P_PPWAIT" Ta No "0x00000010 parent is waiting for child to exec/exit" 293.It Dv "P_PROFIL" Ta No "0x00000020 process has started profiling" 294.It Dv "P_SELECT" Ta No "0x00000040 selecting; wakeup/waiting danger" 295.It Dv "P_SINTR" Ta No "0x00000080 sleep is interruptible" 296.It Dv "P_SUGID" Ta No "0x00000100 process had set id privileges since last exec" 297.It Dv "P_SYSTEM" Ta No "0x00000200 system process: no sigs or stats" 298.It Dv "P_TIMEOUT" Ta No "0x00000400 timing out during sleep" 299.It Dv "P_TRACED" Ta No "0x00000800 process is being traced" 300.It Dv "P_WAITED" Ta No "0x00001000 debugging process has waited for child" 301.It Dv "P_WEXIT" Ta No "0x00002000 working on exiting" 302.It Dv "P_EXEC" Ta No "0x00004000 process called" Xr execve 2 303.It Dv "P_OWEUPC" Ta No "0x00008000 owe process an addupc() call at next ast" 304.\" the routine addupc is not documented in the man pages 305.It Dv "P_FSTRACE" Ta No "0x00010000 tracing via file system" 306.It Dv "P_NOCLDWAIT" Ta No "0x00020000 no zombies when children die" 307.It Dv "P_32" Ta No "0x00040000 32-bit process (used on 64-bit kernels)" 308.It Dv "P_BIGLOCK" Ta No "0x00080000 process needs kernel ``big lock'' to run" 309.It Dv "P_INEXEC" Ta No "0x00100000 process is exec'ing and cannot be traced" 310.El 311.It Ar lim 312The soft limit on memory used, specified via a call to 313.Xr setrlimit 2 . 314.It Ar lstart 315The exact time the command started, using the 316.Dq \&%C 317format described in 318.Xr strftime 3 . 319.It Ar nice 320The process scheduling increment (see 321.Xr setpriority 2 ) . 322.It Ar rss 323the real memory (resident set) size of the process (in 1024 byte units). 324.It Ar start 325The time the command started. 326If the command started less than 24 hours ago, the start time is 327displayed using the 328.Dq %l:%M%p 329format described in 330.Xr strftime 3 . 331If the command started less than 7 days ago, the start time is 332displayed using the 333.Dq %a%p 334format. 335Otherwise, the start time is displayed using the 336.Dq %e%b%y 337format. 338.It Ar state 339The state is given by a sequence of letters, for example, 340.Dq Tn RWNA . 341The first letter indicates the run state of the process: 342.Pp 343.Bl -tag -width indent -compact 344.It D 345Marks a process in disk (or other short term, uninterruptible) wait. 346.It I 347Marks a process that is idle (sleeping for longer than about 20 seconds). 348.It O 349Marks a process running on a processor. 350.It R 351Marks a runnable process, or one that is in the process of creation. 352.It S 353Marks a process that is sleeping for less than about 20 seconds. 354.It T 355Marks a stopped process. 356.It U 357Marks a suspended process. 358.It Z 359Marks a dead process (a 360.Dq zombie ) . 361.El 362.Pp 363Additional characters after these, if any, indicate additional state 364information: 365.Pp 366.Bl -tag -width indent -compact 367.It + 368The process is in the foreground process group of its control terminal. 369.It - 370The LWP is detached (can't be waited for). 371.It \*[Lt] 372The process has raised 373.Tn CPU 374scheduling priority. 375.It a 376The process is using scheduler activations. 377.It E 378The process is trying to exit. 379.It K 380The process is a kernel thread or system process. 381.It l 382The process has multiple LWPs. 383.It N 384The process has reduced 385.Tn CPU 386scheduling priority (see 387.Xr setpriority 2 ) . 388.It s 389The process is a session leader. 390.It V 391The process is suspended during a 392.Xr vfork 2 . 393.It X 394The process is being traced or debugged. 395.El 396.It Ar tt 397An abbreviation for the pathname of the controlling terminal, if any. 398The abbreviation consists of the two letters following 399.Dq Pa /dev/tty , 400or, for the console, 401.Dq co . 402This is followed by a 403.Dq \&- 404if the process can no longer reach that 405controlling terminal (i.e., it has been revoked). 406.It Ar wchan 407The event (an address in the system) on which a process waits. 408When printed numerically, the initial part of the address is 409trimmed off and the result is printed in hex, for example, 0x80324000 prints 410as 324000. 411.El 412.Pp 413When printing using the 414.Ar command 415keyword, a process that has exited and has a parent that has not yet 416waited for the process (in other words, a zombie) is listed as 417.Dq Aq defunct , 418and a process which is blocked while trying to exit is listed as 419.Dq Aq exiting . 420.Pp 421.Nm 422will try to locate the processes' argument vector from the user 423area in order to print the command name and arguments. 424This method is not reliable because a process is allowed to destroy this 425information. 426The 427.Ar ucomm 428(accounting) keyword will always contain the real command name as 429contained in the process structure's 430.Va p_comm 431field. 432.Pp 433If the command vector cannot be located (usually because it has not 434been set, as is the case of system processes and/or kernel threads) 435the command name is printed within square brackets. 436.Pp 437To indicate that the argument vector has been tampered with, 438.Nm 439will append the real command name to the output within parentheses 440if the basename of the first argument in the argument vector 441does not match the contents of the real command name. 442.Pp 443In addition, 444.Nm 445checks for the following two situations and does not append the 446real command name parenthesized: 447.Bl -tag -width indent 448.It -shellname 449The login process traditionally adds a 450.Sq - 451in front of the shell name to indicate a login shell. 452.Nm 453will not append parenthesized the command name if it matches with 454the name in the first argument of the argument vector, skipping 455the leading 456.Sq - . 457.It daemonname: current-activity 458Daemon processes frequently report their current activity by setting 459their name to be like 460.Dq daemonname: current-activity . 461.Nm 462will not append parenthesized the command name, if the string preceding the 463.Sq \&: 464in the first argument of the argument vector matches the command name. 465.El 466.Sh KEYWORDS 467The following is a complete list of the available keywords and their 468meanings. 469Several of them have aliases (keywords which are synonyms). 470.Pp 471.Bl -tag -width groupnames -compact 472.It Ar %cpu 473percentage CPU usage (alias 474.Ar pcpu ) 475.It Ar %mem 476percentage memory usage (alias 477.Ar pmem ) 478.It Ar acflag 479accounting flag (alias 480.Ar acflg ) 481.It Ar comm 482command (the argv[0] value) 483.It Ar command 484command and arguments (alias 485.Ar args ) 486.It Ar cpu 487short-term CPU usage factor (for scheduling) 488.It Ar cpuid 489CPU number the current process or lwp is running on. 490.It Ar ctime 491accumulated CPU time of all children that have exited 492.It Ar egid 493effective group id 494.It Ar egroup 495group name (from egid) 496.It Ar emul 497emulation name 498.It Ar etime 499elapsed time since the process was started, in the form 500.Li [[dd-]hh:]mm:ss 501.It Ar euid 502effective user id 503.It Ar euser 504user name (from euid) 505.It Ar flags 506the process flags, in hexadecimal (alias 507.Ar f ) 508.It Ar gid 509effective group id 510.It Ar group 511group name (from gid) 512.It Ar groupnames 513group names (from group access list) 514.It Ar groups 515group access list 516.It Ar inblk 517total blocks read (alias 518.Ar inblock ) 519.It Ar jobc 520job control count 521.It Ar ktrace 522tracing flags 523.It Ar ktracep 524tracing vnode 525.It Ar laddr 526kernel virtual address of the 527.Tn "struct lwp" 528belonging to the LWP. 529.It Ar lid 530ID of the LWP 531.It Ar lim 532memory use limit 533.It Ar lname 534descriptive name of the LWP 535.It Ar logname 536login name of user who started the process (alias 537.Ar login ) 538.It Ar lstart 539time started 540.It Ar lstate 541symbolic LWP state 542.It Ar majflt 543total page faults 544.It Ar minflt 545total page reclaims 546.It Ar msgrcv 547total messages received (reads from pipes/sockets) 548.It Ar msgsnd 549total messages sent (writes on pipes/sockets) 550.It Ar nice 551nice value (alias 552.Ar ni ) 553.It Ar nivcsw 554total involuntary context switches 555.It Ar nlwp 556number of LWPs in the process 557.It Ar nsigs 558total signals taken (alias 559.Ar nsignals ) 560.It Ar nvcsw 561total voluntary context switches 562.It Ar nwchan 563wait channel (as an address) 564.It Ar oublk 565total blocks written (alias 566.Ar oublock ) 567.It Ar p_ru 568resource usage pointer (valid only for zombie) 569.It Ar paddr 570kernel virtual address of the 571.Tn "struct proc" 572belonging to the process. 573.It Ar pagein 574pageins (same as majflt) 575.It Ar pgid 576process group number 577.It Ar pid 578process 579.Tn ID 580.It Ar ppid 581parent process 582.Tn ID 583.It Ar pri 584scheduling priority 585.It Ar re 586core residency time (in seconds; 127 = infinity) 587.It Ar rgid 588real group 589.Tn ID 590.It Ar rlink 591reverse link on run queue, or 0 592.It Ar rlwp 593Number of LWPs on a processor or run queue 594.It Ar rss 595resident set size 596.It Ar rsz 597resident set size + (text size / text use count) (alias 598.Ar rssize ) 599.It Ar ruid 600real user 601.Tn ID 602.It Ar ruser 603user name (from ruid) 604.It Ar sess 605session pointer 606.It Ar sid 607session 608.Tn ID 609.It Ar sig 610pending signals (alias 611.Ar pending ) 612.It Ar sigcatch 613caught signals (alias 614.Ar caught ) 615.It Ar sigignore 616ignored signals (alias 617.Ar ignored ) 618.It Ar sigmask 619blocked signals (alias 620.Ar blocked ) 621.It Ar sl 622sleep time (in seconds; 127 = infinity) 623.It Ar start 624time started 625.It Ar state 626symbolic process state (alias 627.Ar stat ) 628.It Ar stime 629accumulated system CPU time 630.It Ar svgid 631saved gid from a setgid executable 632.It Ar svgroup 633group name (from svgid) 634.It Ar svuid 635saved uid from a setuid executable 636.It Ar svuser 637user name (from svuid) 638.It Ar tdev 639control terminal device number 640.It Ar time 641accumulated CPU time, user + system (alias 642.Ar cputime ) 643.It Ar tpgid 644control terminal process group 645.Tn ID 646.It Ar tsess 647control terminal session pointer 648.It Ar tsiz 649text size (in Kbytes) 650.It Ar tt 651control terminal name (two letter abbreviation) 652.It Ar tty 653full name of control terminal 654.It Ar uaddr 655kernel virtual address of the 656.Tn "struct user" 657belonging to the LWP. 658.It Ar ucomm 659name to be used for accounting 660.It Ar uid 661effective user 662.Tn ID 663.It Ar upr 664scheduling priority on return from system call (alias 665.Ar usrpri ) 666.It Ar user 667user name (from uid) 668.It Ar utime 669accumulated user CPU time 670.It Ar vsz 671virtual size in Kbytes (alias 672.Ar vsize ) 673.It Ar wchan 674wait channel (as a symbolic name) 675.It Ar xstat 676exit or stop status (valid only for stopped or zombie process) 677.El 678.Sh FILES 679.Bl -tag -width /var/run/kvm.db -compact 680.It Pa /dev 681special files and device names 682.It Pa /dev/drum 683default swap device 684.It Pa /var/run/dev.db 685/dev name database 686.It Pa /var/db/kvm.db 687system namelist database 688.It Pa /netbsd 689default system namelist 690.El 691.Sh SEE ALSO 692.Xr kill 1 , 693.Xr pgrep 1 , 694.Xr pkill 1 , 695.Xr sh 1 , 696.Xr w 1 , 697.Xr kvm 3 , 698.Xr strftime 3 , 699.Xr dev_mkdb 8 , 700.Xr pstat 8 701.Sh BUGS 702Since 703.Nm 704cannot run faster than the system and is run as any other scheduled 705process, the information it displays can never be exact. 706