Back to the command reference

ps

ProcessesFundamentals In simulator In real Linux

Report a snapshot of current processes

Name: ps = process status

You can practise it right away in the simulator, and use it in real Linux mode too.

Description

ps shows a snapshot of current processes (it doesn't refresh). It accepts two option styles: Unix (with a dash, ps -ef) and BSD (without, ps aux), with slightly different columns.

Common columns: PID, PPID (parent), USER, %CPU, %MEM, STAT (R running, S sleeping, Z zombie …) and CMD.

Syntax

ps [OPTION]...

Common options

auxBSD style: every process with CPU and memory
-e / -ASelect all processes
-fFull format: user, parent PID …
-u USEROnly a user's processes
-p PIDOnly these process IDs (comma-separated)
-C NAMEOnly processes called NAME
-o FORMATChoose the columns: ps -eo pid,user,%cpu,%mem,cmd
--sort KEYSort; - means largest first: ps aux --sort=-%mem
--forestShow parents and children as a tree
-LShow threads

Examples

  • $ ps

    Processes in this terminal

    Explain
  • $ ps -ef

    Every process in full format

    Explain
  • $ ps -ef | grep nginx

    Find nginx processes

    Explain

Related