Jump to content

Ps (Unix): Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
mNo edit summary
 
(19 intermediate revisions by 7 users not shown)
Line 1: Line 1:
{{Short description|Standard UNIX utility that displays the currently-running processes}}
{{multiple|
{{manual|date=April 2020}}
{{manual|date=April 2020}}
{{refimprove|date=October 2017}}
{{refimprove|date=October 2017}}
}}
{{Infobox software
{{Infobox software
| name = ps
| name = ps
| logo =
| logo =
| screenshot = PPID.png
| screenshot = Ps command screenshot.png
| screenshot size =
| screenshot size =
| caption = The {{code|ps}} command
| caption = The {{code|ps}} command
Line 12: Line 15:
| latest release version =
| latest release version =
| latest release date =
| latest release date =
| programming language = [[C (programming language)|C]]
| operating system = [[Unix]], [[Unix-like]], [[Plan 9 from Bell Labs|Plan 9]], [[KolibriOS]]
| operating system = [[Unix]], [[Unix-like]], [[Plan 9 from Bell Labs|Plan 9]], [[Inferno (operating system)|Inferno]], [[KolibriOS]], [[IBM i]]
| platform = [[Cross-platform]]
| genre = [[Command (computing)|Command]]
| genre = [[Command (computing)|Command]]
| license =
| license = Plan 9: [[MIT License]]
| website =
| website =
}}
}}
In most [[Unix]] and [[Unix-like]] [[operating systems]], the '''<code>ps</code>''' program (short for "'''p'''rocess '''s'''tatus") displays the currently-running [[process (computing)|processes]]. A related Unix utility named [[Top (software)|top]] provides a real-time view of the running processes.
In most [[Unix]] and [[Unix-like operating system]]s, the '''<code>ps</code>''' (''process status'') program displays the currently-running [[process (computing)|processes]]. The related Unix utility <code>[[top (software)|top]]</code> provides a real-time view of the running processes.


==Implementations==
In [[Windows PowerShell]], <code>ps</code> is a predefined [[Alias (command)|command alias]] for the <code>Get-Process</code> cmdlet, which essentially serves the same purpose.
[[KolibriOS]] includes an implementation of the {{code|ps}} [[command (computing)|command]].<ref>{{Cite web|url=http://wiki.kolibrios.org/wiki/Shell|title=Shell - KolibriOS wiki}}</ref> The {{Mono|ps}} command has also been ported to the [[IBM i]] operating system.<ref>{{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 }}</ref> In [[Windows PowerShell]], <code>ps</code> is a predefined [[Alias (command)|command alias]] for the <code>Get-Process</code> cmdlet, which essentially serves the same purpose.

[[KolibriOS]] includes an implementation of the {{code|ps}} [[command (computing)|command]].<ref>http://wiki.kolibrios.org/wiki/Shell</ref>


==Examples==
==Examples==
For example:
<syntaxhighlight lang="console">
<syntaxhighlight lang="console">
# ps
# ps
Line 33: Line 36:
</syntaxhighlight>
</syntaxhighlight>


Users can [[Pipeline (Unix)|pipeline]] <code>ps</code> with other commands, such as [[Less (Unix)|less]] to view the process status output one page at a time:
Users can also utilize the <tt>ps</tt> command in conjunction with the <code>[[grep]]</code> command (see the <tt>[[pgrep]]</tt> and <tt>[[pkill]]</tt> commands) to find information about a single process, such as its id:


<syntaxhighlight lang="console">
<syntaxhighlight lang="console">
$ ps -A | less
</syntaxhighlight>

Users can also utilize the <code>ps</code> command in conjunction with the <code>[[grep]]</code> command (see the <code>[[pgrep]]</code> and <code>[[pkill]]</code> commands) to find information about a single process, such as its id:<syntaxhighlight lang="console">
$ # Trying to find the PID of `firefox-bin` which is 2701
$ # Trying to find the PID of `firefox-bin` which is 2701
$ ps -A | grep firefox-bin
$ ps -A | grep firefox-bin
Line 41: Line 48:
</syntaxhighlight>
</syntaxhighlight>


The use of <tt>[[pgrep]]</tt> simplifies the syntax and avoids potential race conditions:
The use of <code>[[pgrep]]</code> simplifies the syntax and avoids potential race conditions:
<syntaxhighlight lang="console">
<syntaxhighlight lang="console">
$ pgrep -l firefox-bin
$ pgrep -l firefox-bin
Line 54: Line 61:
</syntaxhighlight>
</syntaxhighlight>


==Breakdown==
==Header line==
{| class="wikitable"
{| class="wikitable"
|-
|-
Line 98: Line 105:


==Options==
==Options==
<tt>ps</tt> has many options. On [[operating system]]s that support the [[Single UNIX Specification|SUS]] and [[POSIX]] standards, <tt>ps</tt> commonly runs with the options '''-ef''', where "-e" selects '''e'''very process and "-f" chooses the "'''f'''ull" output format. Another common option on these systems is '''-l''', which specifies the "'''l'''ong" output format.
<code>ps</code> has many options. On [[operating system]]s that support the [[Single UNIX Specification|SUS]] and [[POSIX]] standards, <code>ps</code> commonly runs with the options '''-ef''', where "-e" selects '''e'''very process and "-f" chooses the "'''f'''ull" output format. Another common option on these systems is '''-l''', which specifies the "'''l'''ong" 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 variable]]s.) On such systems, <tt>ps</tt> commonly runs with the non-standard options '''aux''', where "a" lists all processes on a [[Computer terminal|terminal]], including those of other users, "x" lists all processes without [[controlling terminal]]s 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.
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 variable]]s.) On such systems, <code>ps</code> commonly runs with the non-standard options '''aux''', where "a" lists all processes on a [[Computer terminal|terminal]], including those of other users, "x" lists all processes without [[controlling terminal]]s 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==
==See also==
* [[Task manager]]
* [[Task manager]]
* <code>[[kill (command)|kill]]</code>
* [[kill (command)]]
* [[List of Unix commands]]
* [[List of Unix commands]]
* <code>[[nmon]]</code> &mdash; a system monitor tool for the AIX and Linux operating systems.
* [[nmon]] a system monitor tool for AIX and Linux operating systems
* [[pstree (Unix)]]
* <code>[[pgrep]]</code>
* [[lsof]]
* <code>[[pstree (Unix)|pstree]]</code>
* <code>[[top (Unix)|top]]</code>
* <code>[[lsof]]</code>


==References==
==References==
{{reflist}}
{{Reflist}}
*{{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.co.uk/books?id=OCFKdl3wEDIC|accessdate=16 October 2017|language=en}}


==Further reading==
==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|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}}


==External links==
==External links==
{{Wikibooks|Guide to Unix|Commands}}
* {{man|cu|ps|SUS}}
* {{man|cu|ps|SUS}}
* {{man|1|ps|Plan 9}}
* {{man|1|ps|Plan 9}}
* {{man|1|ps|Inferno}}
* [http://www.cyberciti.biz/faq/show-all-running-processes-in-linux/ Show all running processes in Linux using ps command]
* [http://www.cyberciti.biz/faq/show-all-running-processes-in-linux/ Show all running processes in Linux using ps command]
* [http://kb.iu.edu/data/afnv.html In Unix, what do the output fields of the ps command mean?]
* [http://kb.iu.edu/data/afnv.html In Unix, what do the output fields of the ps command mean?]


{{Unix commands}}
{{Unix commands}}
{{Plan 9 commands}}


{{lowercase}}
{{lowercase}}
[[Category:Unix SUS2008 utilities]]
[[Category:Unix SUS2008 utilities]]
[[Category:Unix process- and task-management-related software]]
[[Category:Unix process- and task-management-related software]]
[[Category:Plan 9 commands]]
[[Category:Inferno (operating system) commands]]
[[Category:IBM i Qshell commands]]

Latest revision as of 20:16, 15 June 2024

ps
Original author(s)AT&T Bell Laboratories
Developer(s)Various open-source and commercial developers
Initial releaseFebruary 1973; 51 years ago (1973-02)
Written inC
Operating systemUnix, Unix-like, Plan 9, Inferno, KolibriOS, IBM i
PlatformCross-platform
TypeCommand
LicensePlan 9: MIT License

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

[edit]

KolibriOS includes an implementation of the ps command.[1] The ps command has also been ported to the IBM i operating system.[2] In Windows PowerShell, ps is a predefined command alias for the Get-Process cmdlet, which essentially serves the same purpose.

Examples

[edit]
# 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:

# 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

[edit]
Column Header Contents
%CPU How much of the CPU the process is using
%MEM How much memory the process is using
ADDR Memory address of the process
C or CP CPU usage and scheduling information
COMMAND* Name of the process, including arguments, if any
NI nice value
F Flags
PID Process ID number
PPID ID number of the process's parent process
PRI Priority of the process
RSS Resident set size
S or STAT Process status code
START or STIME Time when the process started
VSZ Virtual memory usage
TIME The amount of CPU time used by the process
TT or TTY Terminal associated with the process
UID or USER Username of the process's owner
WCHAN Memory address of the event the process is waiting for

* = Often abbreviated

Options

[edit]

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

[edit]

References

[edit]
  1. ^ "Shell - KolibriOS wiki".
  2. ^ IBM. "IBM System i Version 7.2 Programming Qshell" (PDF). IBM. Retrieved 2020-09-05.

Further reading

[edit]
[edit]