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