Ps (Unix)

Revision as of 09:55, 3 January 2025 by imported>NotAG on AWB (replace {{manual}} with {{how-to}} per TfD)
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)

Template:Short description Template:Multiple issues {{#invoke:Infobox|infobox}}Template:Template other{{#invoke:Check for unknown parameters | check | showblankpositional=1 | unknown = Template:Main other | preview = Page using Template:Infobox software with unknown parameter "_VALUE_"|ignoreblank=y | AsOf | author | background | bodystyle | caption | collapsetext | collapsible | developer | discontinued | engine | engines | genre | included with | language | language count | language footnote | latest preview date | latest preview version | latest release date | latest release version | latest_preview_date | latest_preview_version | latest_release_date | latest_release_version | licence | license | logo | logo alt | logo caption | logo upright | logo size | logo title | logo_alt | logo_caption | logo_upright | logo_size | logo_title | middleware | module | name | operating system | operating_system | other_names | platform | programming language | programming_language | released | replaced_by | replaces | repo | screenshot | screenshot alt | screenshot upright | screenshot size | screenshot title | screenshot_alt | screenshot_upright | screenshot_size | screenshot_title | service_name | size | standard | title | ver layout | website | qid }}Template:Main other 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.

ImplementationsEdit

KolibriOS includes an implementation of the <syntaxhighlight lang="text" class="" style="" inline="1">ps</syntaxhighlight> command.<ref>{{#invoke:citation/CS1|citation |CitationClass=web }}</ref> The Template:Mono command has also been ported to the IBM i operating system.<ref>{{#invoke:citation/CS1|citation |CitationClass=web }}</ref> In Windows PowerShell, ps is a predefined command alias for the Get-Process cmdlet, which essentially serves the same purpose.

ExamplesEdit

<syntaxhighlight lang="console">

  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 </syntaxhighlight>

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

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

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:<syntaxhighlight lang="console"> $ # Trying to find the PID of `firefox-bin` which is 2701 $ ps -A | grep firefox-bin 2701 ? 22:16:04 firefox-bin </syntaxhighlight>

The use of pgrep simplifies the syntax and avoids potential race conditions: <syntaxhighlight lang="console"> $ pgrep -l firefox-bin 2701 firefox-bin </syntaxhighlight>

To see every process running as root in user format: <syntaxhighlight lang="console">

  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 -- </syntaxhighlight>

Header lineEdit

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

OptionsEdit

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 alsoEdit

ReferencesEdit

Template:Reflist

Further readingEdit

External linksEdit

Template:Sister project

Template:Unix commands Template:Plan 9 commands

Template:Lowercase title