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