ps (Unix)

{{Short description|Standard UNIX utility that displays the currently-running processes}}

{{multiple issues|

{{how-to|date=April 2020}}

{{more citations needed|date=October 2017}}

}}

{{Infobox software

| name = ps

| logo =

| screenshot = Ps command screenshot.png

| screenshot size =

| caption = The {{code|ps}} command

| author = AT&T Bell Laboratories

| developer = Various open-source and commercial developers

| released = {{Start date and age|1973|2}}

| latest release version =

| latest release date =

| programming language = C

| operating system = Unix, Unix-like, Plan 9, Inferno, KolibriOS, IBM i

| platform = Cross-platform

| genre = Command

| license = Plan 9: MIT License

| website =

}}

In most Unix and Unix-like operating systems, the ps (process status) program displays the currently-running processes. The related Unix utility top provides a real-time view of the running processes.

Implementations

KolibriOS includes an implementation of the {{code|ps}} command.{{Cite web|url=http://wiki.kolibrios.org/wiki/Shell|title=Shell - KolibriOS wiki}} The {{Mono|ps}} command has also been ported to the IBM i operating system.{{cite web |title=IBM System i Version 7.2 Programming Qshell |language=en |author=IBM |website=IBM |author-link=IBM |url=https://www.ibm.com/support/knowledgecenter/ssw_ibm_i_74/rzahz/rzahzpdf.pdf?view=kc |access-date=2020-09-05 }} In Windows PowerShell, ps is a predefined command alias for the Get-Process cmdlet, which essentially serves the same purpose.

Examples

  1. ps

PID TTY TIME CMD

7431 pts/0 00:00:00 su

7434 pts/0 00:00:00 bash

18585 pts/0 00:00:00 ps

Users can pipeline ps with other commands, such as less to view the process status output one page at a time:

$ ps -A | less

Users can also utilize the ps command in conjunction with the grep command (see the pgrep and pkill commands) to find information about a single process, such as its id:

$ # Trying to find the PID of `firefox-bin` which is 2701

$ ps -A | grep firefox-bin

2701 ? 22:16:04 firefox-bin

The use of pgrep simplifies the syntax and avoids potential race conditions:

$ pgrep -l firefox-bin

2701 firefox-bin

To see every process running as root in user format:

  1. ps -U root -u

USER PID %CPU %MEM VSZ RSS TT STAT STARTED TIME COMMAND

root 1 0.0 0.0 9436 128 - ILs Sun00AM 0:00.12 /sbin/init --

Header line

class="wikitable"
Column HeaderContents
%CPUHow much of the CPU the process is using
%MEMHow much memory the process is using
ADDRMemory address of the process
C or CPCPU usage and scheduling information
COMMAND*Name of the process, including arguments, if any
NInice value
FFlags
PIDProcess ID number
PPIDID number of the process's parent process
PRIPriority of the process
RSSResident set size
S or STATProcess status code
START or STIMETime when the process started
VSZVirtual memory usage
TIMEThe amount of CPU time used by the process
TT or TTYTerminal associated with the process
UID or USERUsername of the process's owner
WCHANMemory address of the event the process is waiting for

* = Often abbreviated

Options

ps has many options. On operating systems that support the SUS and POSIX standards, ps commonly runs with the options -ef, where "-e" selects every process and "-f" chooses the "full" output format. Another common option on these systems is -l, which specifies the "long" output format.

Most systems derived from BSD fail to accept the SUS and POSIX standard options because of historical conflicts. (For example, the "e" or "-e" option will display environment variables.) On such systems, ps commonly runs with the non-standard options aux, where "a" lists all processes on a terminal, including those of other users, "x" lists all processes without controlling terminals and "u" adds a column for the controlling user for each process. For maximum compatibility, there is no "-" in front of the "aux". "ps auxww" provides complete information about the process, including all parameters.

See also

References

{{Reflist}}

Further reading

  • {{Cite book|author-last=McElhearn|author-first=Kirk|title=The Mac OS X Command Line: Unix Under the Hood|date=2006|publisher=John Wiley & Sons|isbn=978-0470113851}}
  • {{Cite book|last1=Shotts (Jr)|first1=William E.|title=The Linux Command Line: A Complete Introduction|date=2012|publisher=No Starch Press|isbn=9781593273897|pages=96–98|url=https://books.google.com/books?id=OCFKdl3wEDIC|access-date=16 October 2017|language=en}}