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