1.\" $OpenBSD: ps.1,v 1.98 2015/02/11 00:43:33 guenther Exp $ 2.\" $NetBSD: ps.1,v 1.16 1996/03/21 01:36:28 jtc Exp $ 3.\" 4.\" Copyright (c) 1980, 1990, 1991, 1993, 1994 5.\" The Regents of the University of California. All rights reserved. 6.\" 7.\" Redistribution and use in source and binary forms, with or without 8.\" modification, are permitted provided that the following conditions 9.\" are met: 10.\" 1. Redistributions of source code must retain the above copyright 11.\" notice, this list of conditions and the following disclaimer. 12.\" 2. Redistributions in binary form must reproduce the above copyright 13.\" notice, this list of conditions and the following disclaimer in the 14.\" documentation and/or other materials provided with the distribution. 15.\" 3. Neither the name of the University nor the names of its contributors 16.\" may be used to endorse or promote products derived from this software 17.\" without specific prior written permission. 18.\" 19.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 20.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 23.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29.\" SUCH DAMAGE. 30.\" 31.\" @(#)ps.1 8.3 (Berkeley) 4/18/94 32.\" 33.Dd $Mdocdate: February 11 2015 $ 34.Dt PS 1 35.Os 36.Sh NAME 37.Nm ps 38.Nd display process status 39.Sh SYNOPSIS 40.Nm ps 41.Sm off 42.Op Fl AaCceHhjkLlmrSTuvwx 43.Sm on 44.Op Fl M Ar core 45.Op Fl N Ar system 46.Op Fl O Ar fmt 47.Op Fl o Ar fmt 48.Op Fl p Ar pid 49.Op Fl t Ar tty 50.Op Fl U Ar username 51.Op Fl W Ar swap 52.Sh DESCRIPTION 53The 54.Nm 55utility displays information about active processes. 56When given no options, 57.Nm 58prints information about processes of the current user that have a 59controlling terminal. 60.Pp 61The information displayed is selected based on a set of keywords (and for 62even more control, see the 63.Fl L , 64.Fl O , 65and 66.Fl o 67options). 68The default output format includes, for each process, the process's ID, 69controlling terminal, state, CPU time (including both user and system time), 70and associated command. 71.Pp 72The options are as follows: 73.Bl -tag -width Ds 74.It Fl A 75Display information about processes for all users, including those without controlling 76terminals. 77.It Fl a 78Display information about processes for all users with controlling terminals. 79.It Fl C 80Change the way the CPU percentage is calculated by using a 81.Dq raw 82CPU calculation that ignores 83.Dq resident 84time (this normally has 85no effect). 86.It Fl c 87Do not display full command with arguments, but only the 88executable name. 89This may be somewhat confusing; for example, all 90.Xr sh 1 91scripts will show as 92.Dq sh . 93.It Fl e 94Display the environment as well. 95.It Fl H 96Also display information about kernel visible threads. 97.It Fl h 98Repeat the information header as often as necessary to guarantee one 99header per page of information. 100.It Fl j 101Print information associated with the following keywords: 102user, pid, ppid, pgid, sess, jobc, state, tt, time, and command. 103.It Fl k 104Also display information about kernel threads. 105.It Fl L 106List the set of available keywords. 107This option should not be specified with other options. 108.It Fl l 109Display information associated with the following keywords: 110uid, pid, ppid, cpu, pri, nice, vsz, rss, wchan, state, tt, time, 111and command. 112.It Fl M Ar core 113Extract values associated with the name list from the specified core 114instead of the running kernel. 115.It Fl m 116Sort by memory usage, instead of by start time ID. 117.It Fl N Ar system 118Extract the name list from the specified system instead of the running kernel. 119.It Fl O Ar fmt 120Add the information associated with the space or comma separated list 121of keywords specified, after the process ID, 122in the default information 123display. 124Keywords may be appended with an equals sign 125.Pq Sq = 126and a string. 127This causes the printed header to use the specified string instead of 128the standard header. 129.It Fl o Ar fmt 130Display information associated with the space or comma separated list 131of keywords specified. 132Keywords may be appended with an equals sign 133.Pq Sq = 134and a string. 135This causes the printed header to use the specified string instead of 136the standard header. 137.It Fl p Ar pid 138Display information associated with the specified process ID. 139.It Fl r 140Sort by current CPU usage, instead of by start time ID. 141.It Fl S 142Change the way the process time is calculated by summing all exited 143children to their parent process. 144.It Fl T 145Display information about processes attached to the device associated 146with the standard input. 147.It Fl t Ar tty 148Display information about processes attached to the specified terminal 149device. 150.It Fl U Ar username 151Display the processes belonging to the specified 152.Ar username . 153.It Fl u 154Display information associated with the following keywords: 155user, pid, %cpu, %mem, vsz, rss, tt, state, start, time, and command. 156The 157.Fl u 158option implies the 159.Fl r 160option. 161.It Fl v 162Display information associated with the following keywords: 163pid, state, time, sl, re, pagein, vsz, rss, lim, tsiz, 164%cpu, %mem, and command. 165The 166.Fl v 167option implies the 168.Fl m 169option. 170.It Fl W Ar swap 171When not using the running kernel, 172extract swap information from the specified file. 173.It Fl w 174Use 132 columns to display information, instead of the default, which 175is the window size. 176If the 177.Fl w 178option is specified more than once, 179.Nm 180will use as many columns as necessary without regard for window size. 181.It Fl x 182Display information about processes without controlling terminals. 183.El 184.Sh KEYWORDS 185The following is a complete list of the available keywords 186and their meanings. 187Several of them have aliases, 188which are also noted. 189.Bl -tag -width "sigignoreXX" -offset 3n 190.It Cm %cpu 191Alias: 192.Cm pcpu . 193The CPU utilization of the process; this is a decaying average over up to 194a minute of previous (real) time. 195Since the time base over which this is computed varies (since processes may 196be very young) it is possible for the sum of all 197.Cm %cpu 198fields to exceed 100%. 199.It Cm %mem 200Alias: 201.Cm pmem . 202The percentage of real memory used by this process. 203.It Cm acflag 204Alias: 205.Cm acflg . 206Accounting flag. 207.It Cm command 208Alias: 209.Cm args . 210Command and arguments. 211.It Cm cpu 212Short-term CPU usage factor (for scheduling). 213.It Cm cpuid 214CPU ID (zero on single processor systems). 215.It Cm cwd 216Current working directory. 217.It Cm dsiz 218Data size, in Kilobytes. 219.It Cm emul 220Name of system call emulation environment. 221.It Cm flags 222Alias: 223.Cm f . 224The thread flags (in hexadecimal), as defined in the include file 225.In sys/proc.h : 226.Bd -literal 227P_INKTR 0x1 writing ktrace(2) record 228P_PROFPEND 0x2 this thread needs SIGPROF 229P_ALRMPEND 0x4 this thread needs SIGVTALRM 230P_SIGSUSPEND 0x8 need to restore before-suspend mask 231P_CANTSLEEP 0x10 this thread is not permitted to sleep 232P_SELECT 0x40 selecting; wakeup/waiting danger 233P_SINTR 0x80 sleep is interruptible 234P_SYSTEM 0x200 system process: no sigs, stats, or 235 swapping 236P_TIMEOUT 0x400 timing out during sleep 237P_WEXIT 0x2000 working on exiting 238P_OWEUPC 0x8000 profiling sample needs recording 239P_SUSPSINGLE 0x80000 need to suspend for single threading 240P_SYSTRACE 0x400000 systrace(4) policy is active 241P_CONTINUED 0x800000 thread has continued after a stop 242P_THREAD 0x4000000 not the original thread 243P_SUSPSIG 0x8000000 stopped because of a signal 244P_SOFTDEP 0x10000000 stuck processing softdep worklist 245P_CPUPEG 0x40000000 do not move to another cpu 246.Ed 247.It Cm gid 248Effective group. 249.It Cm group 250Text name of effective group ID. 251.It Cm inblk 252Alias: 253.Cm inblock . 254Total blocks read. 255.It Cm jobc 256Job control count. 257.It Cm ktrace 258Tracing flags. 259.It Cm ktracep 260Tracing vnode. 261.It Cm lim 262The soft limit on memory used, specified via a call to 263.Xr setrlimit 2 . 264.It Cm logname 265Alias: 266.Cm login . 267Login name of user who started the process. 268.It Cm lstart 269The exact time the command started, using the 270.Dq %c 271format described in 272.Xr strftime 3 . 273.It Cm majflt 274Total page faults. 275.It Cm maxrss 276Maximum resident set size (in 1024 byte units). 277.It Cm minflt 278Total page reclaims. 279.It Cm msgrcv 280Total messages received (reads from pipes/sockets). 281.It Cm msgsnd 282Total messages sent (writes on pipes/sockets). 283.It Cm nice 284Alias: 285.Cm ni . 286The process scheduling increment (see 287.Xr setpriority 2 ) . 288.It Cm nivcsw 289Total involuntary context switches. 290.It Cm nsigs 291Alias: 292.Cm nsignals . 293Total signals taken. 294.It Cm nswap 295Total swaps in/out. 296.It Cm nvcsw 297Total voluntary context switches. 298.It Cm nwchan 299Wait channel (as an address). 300.It Cm oublk 301Alias: 302.Cm oublock . 303Total blocks written. 304.It Cm p_ru 305Resource usage (valid only for zombie processes). 306.It Cm paddr 307Swap address. 308.It Cm pagein 309Pageins (same as 310.Cm majflt ) . 311.It Cm pgid 312Process group number. 313.It Cm pid 314Process ID. 315.It Cm ppid 316Parent process ID. 317.It Cm pri 318Scheduling priority. 319.It Cm procflags 320The process flags (in hexadecimal), as defined in the include file 321.In sys/proc.h : 322.Bd -literal 323PS_CONTROLT 0x1 process has a controlling 324 terminal 325PS_EXEC 0x2 process called exec(3) 326PS_INEXEC 0x4 process is doing an exec right 327 now 328PS_EXITING 0x8 process is exiting 329PS_SUGID 0x10 process had set ID privileges 330 since last exec 331PS_SUGIDEXEC 0x20 last exec(3) was set[ug]id 332PS_PPWAIT 0x40 parent is waiting for process 333 to exec/exit 334PS_ISPWAIT 0x80 process is parent of PPWAIT 335 child 336PS_PROFIL 0x100 process has started profiling 337PS_TRACED 0x200 process is being traced 338PS_WAITED 0x400 debugging process has waited 339 for child 340PS_COREDUMP 0x800 busy coredumping 341PS_SINGLEEXIT 0x1000 other threads must die 342PS_SINGLEUNWIND 0x2000 other threads must unwind 343PS_NOZOMBIE 0x4000 pid 1 waits for me instead of 344 dad 345PS_STOPPED 0x8000 just stopped, need to send 346 SIGCHLD 347PS_SYSTEM 0x10000 No signals, stats or swapping 348PS_EMBRYO 0x20000 New process, not yet fledged 349PS_ZOMBIE 0x40000 Dead and ready to be waited for 350PS_NOBROADCASTKILL 0x80000 Process excluded from kill -1 351.Ed 352.It Cm re 353Core residency time (in seconds; 127 = infinity). 354.It Cm rgid 355Real group ID. 356.It Cm rgroup 357Text name of real group ID. 358.It Cm rlink 359Reverse link on run queue, or 0. 360.It Cm rss 361The real memory (resident set) size of the process (in 1024 byte units). 362.It Cm rsz 363Alias: 364.Cm rssize . 365Resident set size + (text size / text use count). 366.It Cm rtable 367Routing table. 368.It Cm ruid 369Real user ID. 370.It Cm ruser 371User name (from 372.Cm ruid ) . 373.It Cm sess 374Session pointer. 375.It Cm sig 376Alias: 377.Cm pending . 378Pending signals. 379.It Cm sigcatch 380Alias: 381.Cm caught . 382Caught signals. 383.It Cm sigignore 384Alias: 385.Cm ignored . 386Ignored signals. 387.It Cm sigmask 388Alias: 389.Cm blocked . 390Blocked signals. 391.It Cm sl 392Sleep time (in seconds; 127 = infinity). 393.It Cm ssiz 394Stack size, in Kilobytes. 395.It Cm start 396Alias: 397.Cm etime . 398The time the command started. 399If the command started less than 24 hours ago, the start time is 400displayed using the 401.Dq %l:%M%p 402format described in 403.Xr strftime 3 . 404If the command started less than 7 days ago, the start time is 405displayed using the 406.Dq %a%I%p 407format. 408Otherwise, the start time is displayed using the 409.Dq %e%b%y 410format. 411.It Cm state 412Alias: 413.Cm stat . 414The state is given by a sequence of letters, for example, 415.Dq RWN . 416The first letter indicates the run state of the process: 417.Pp 418.Bl -tag -width indent -compact 419.It D 420Marks a process in disk (or other short term, uninterruptible) wait. 421.It I 422Marks a process that is idle (sleeping for longer than about 20 seconds). 423.It R 424Marks a runnable process. 425.It S 426Marks a process that is sleeping for less than about 20 seconds. 427.It T 428Marks a stopped process. 429.It Z 430Marks a dead process (a 431.Dq zombie ) . 432.El 433.Pp 434Additional characters after these, if any, indicate additional state 435information: 436.Pp 437.Bl -tag -width indent -compact 438.It + 439The process is in the foreground process group of its control terminal. 440.It \*(Lt 441The process has a raised CPU 442scheduling priority (see 443.Xr setpriority 2 ) . 444.It \*(Gt 445The process has specified a soft limit on memory requirements and is 446currently exceeding that limit; such a process is (necessarily) not 447swapped. 448.\" .It A 449.\" the process has asked for random page replacement 450.\" .Pf ( Dv MADV_RANDOM , 451.\" from 452.\" .Xr madvise 2 , 453.\" for example, 454.\" .Xr lisp 1 455.\" in a garbage collect). 456.It E 457The process is trying to exit. 458.It K 459The process is a kernel thread. 460.It N 461The process has a reduced CPU 462scheduling priority. 463.\" .It S 464.\" The process has asked for FIFO 465.\" page replacement 466.\" .Pf ( Dv MADV_SEQUENTIAL , 467.\" from 468.\" .Xr madvise 2 , 469.\" for example, a large image processing program using virtual memory to 470.\" sequentially address voluminous data). 471.It s 472The process is a session leader. 473.It V 474The process is suspended during a 475.Xr vfork 2 . 476.It X 477The process is being traced or debugged. 478.It x 479The process is being monitored by 480.Xr systrace 1 . 481.It / Ns Ar n 482On multiprocessor machines, specifies processor number 483.Ar n . 484.El 485.It Cm svgid 486Saved GID from a setgid executable. 487.It Cm svuid 488Saved UID from a setuid executable. 489.It Cm tdev 490Control terminal device number. 491.It Cm time 492Alias: 493.Cm cputime . 494Accumulated CPU time, user + system. 495.It Cm tpgid 496Control terminal process group ID. 497.\".It trss 498.\"Text resident set size, in Kilobytes. 499.It Cm tsess 500Control terminal session pointer. 501.It Cm tsiz 502Text size, in Kilobytes. 503.It Cm tt 504An abbreviation for the pathname of the controlling terminal, if any. 505The abbreviation consists of the two letters following 506.Dq /dev/tty , 507or, for the console, 508.Dq co . 509This is followed by a 510.Sq - 511if the process can no longer reach that 512controlling terminal (i.e. it has been revoked). 513.It Cm tty 514Full name of control terminal. 515.It Cm ucomm 516Alias: 517.Cm comm . 518Name to be used for accounting. 519.It Cm uid 520Effective user ID. 521.It Cm upr 522Alias: 523.Cm usrpri . 524Scheduling priority on return from system call. 525.It Cm user 526User name (from 527.Cm uid ) . 528.It Cm vsz 529Alias: 530.Cm vsize . 531Virtual size, in Kilobytes. 532.It Cm wchan 533The event (an address in the system) on which a process waits. 534When printed numerically, the initial part of the address is 535trimmed off and the result is printed in hex; for example, 0x80324000 prints 536as 324000. 537.It Cm xstat 538Exit or stop status (valid only for stopped or zombie process). 539.El 540.Sh ENVIRONMENT 541The following environment variables affect the execution of 542.Nm : 543.Bl -tag -width "COLUMNS" 544.It Ev COLUMNS 545If set, specifies the user's preferred output width in column positions. 546By default, 547.Nm 548attempts to automatically determine the terminal width. 549.It Ev TZ 550The time zone to use when displaying dates. 551See 552.Xr environ 7 553for more information. 554.El 555.Sh FILES 556.Bl -tag -width "/var/db/kvm_bsd.dbXXX" -compact 557.It Pa /dev 558special files and device names 559.It Pa /var/db/kvm_bsd.db 560system namelist database 561.It Pa /var/run/dev.db 562.Pa /dev 563name database 564.El 565.Sh EXIT STATUS 566.Ex -std ps 567.Sh EXAMPLES 568Display information on all system processes: 569.Pp 570.Dl $ ps -auxw 571.Sh SEE ALSO 572.Xr fstat 1 , 573.Xr kill 1 , 574.Xr netstat 1 , 575.Xr pgrep 1 , 576.Xr pkill 1 , 577.Xr procmap 1 , 578.Xr systat 1 , 579.Xr top 1 , 580.Xr w 1 , 581.Xr kvm 3 , 582.Xr strftime 3 , 583.Xr dev_mkdb 8 , 584.Xr iostat 8 , 585.Xr pstat 8 , 586.Xr vmstat 8 587.Sh STANDARDS 588The 589.Nm 590utility is compliant with the 591.St -p1003.1-2008 592specification, 593except that the flag 594.Op Fl G 595is unsupported and 596the flags 597.Op Fl ptU 598support only single arguments, not lists. 599.Pp 600The flags 601.Op Fl defglnu 602are marked by 603.St -p1003.1-2008 604as being an X/Open System Interfaces option. 605Of these, 606.Op Fl dfgn 607are not supported by this implementation of 608.Nm ; 609behaviour for the flags 610.Op Fl elu 611differs between this implementation and the 612X/Open System Interfaces option of 613.St -p1003.1-2008 . 614.Pp 615The flags 616.Op Fl CcHhjkLMmNOrSTvWwx 617are extensions to 618.St -p1003.1-2008 . 619.Pp 620Only the following keywords are recognised by 621.St -p1003.1-2008 : 622.Cm args , 623.Cm comm , 624.Cm etime , 625.Cm group , 626.Cm nice , 627.Cm pcpu , 628.Cm pgid , 629.Cm pid , 630.Cm ppid , 631.Cm rgroup , 632.Cm ruser , 633.Cm time , 634.Cm tty , 635.Cm user , 636and 637.Cm vsz . 638.Sh HISTORY 639A 640.Nm 641command appeared in 642.At v3 643in section 8 of the manual. 644.Sh CAVEATS 645When printing using the 646.Cm command 647keyword, a process that has exited and 648has a parent that has not yet waited for the process (in other words, a zombie) 649is listed as 650.Dq Aq defunct , 651and a process which is blocked while trying 652to exit is listed as 653.Dq Aq exiting . 654.Nm 655makes an educated guess as to the file name and arguments given when the 656process was created by examining memory or the swap area. 657The method is inherently somewhat unreliable and in any event a process 658is entitled to destroy this information, so the names cannot be depended 659on too much. 660The 661.Cm ucomm 662(accounting) keyword can, however, be depended on. 663.Sh BUGS 664Since 665.Nm 666cannot run faster than the system and is run as any other scheduled 667process, the information it displays can never be exact. 668