Linux ps Command: Display Active Processes
The ps (process status) command is a core utility in
Linux used to view an instantaneous snapshot of currently running
processes. This article explains the internal mechanisms behind how
ps extracts process data from the operating system's
kernel, the primary syntax standards used to query this data, how to
interpret the default output fields, and common practical examples for
managing system workloads.
How ps Retrieves
Process Data
Unlike graphical monitors or continuous CLI tools like
top, the ps command does not monitor the
system continuously. Instead, it captures the exact state of active
tasks at the specific millisecond the command is executed.
The command works by reading the /proc filesystem, a
virtual pseudo-filesystem created on the fly by the Linux kernel. The
kernel maintains dedicated subdirectories for every active task, named
after their numerical Process ID (PID) (for example,
/proc/1234/). Within each directory, ps parses
specific kernel data files:
- /proc/[PID]/stat: Contains status information about the process, such as CPU utilization, state, and execution flags.
- /proc/[PID]/status: Human-readable process metadata, including memory consumption and user identifiers.
- /proc/[PID]/cmdline: The complete command-line invocation that launched the process.
The ps utility translates this raw kernel data into
formatted, human-readable text columns displayed in your terminal.
The Three Syntax Styles
Linux ps is unique because it supports three distinct
command syntaxes due to historical Unix developments:
- UNIX (POSIX) Style: Options must be preceded by a
single dash (e.g.,
ps -ef). - BSD Style: Options must not use a dash (e.g.,
ps aux). - GNU Long Options: Options are preceded by two
dashes (e.g.,
ps --forest).
These styles can be mixed, though doing so can occasionally produce conflicting behavior.
Standard Output Columns
When running general commands such as ps aux or
ps -ef, the output organizes process information into
specific headers:
- USER / UID: The user account that owns and executed the process.
- PID: The unique Process Identifier.
- %CPU / %MEM: The percentage of available processor power and physical RAM currently consumed.
- VSZ and RSS: Virtual memory size (in KiB) versus Resident Set Size (non-swapped physical memory actively used).
- TTY: The terminal device controlling the process (a
?indicates a daemon or system service detached from any terminal). - STAT / S: The current process state. Common
indicators include
R(running),S(interruptible sleep),D(uninterruptible disk sleep),T(stopped), andZ(zombie). - START / TIME: When the process was initiated and the total cumulative CPU time consumed.
- COMMAND / CMD: The executable name, script, or system binary along with any arguments passed.
Essential ps Commands
To inspect processes effectively, administrators rely on a few common flag combinations:
- View every active system process (BSD syntax):
ps aux - View every active system process with full detail (POSIX
syntax):
ps -ef - Display a process hierarchy (tree view):
ps -ejH # or using GNU style: ps aux --forest - View threads for a specific PID:
ps -T -p <PID> - Custom output columns for tailored monitoring:
ps -eo pid,user,%cpu,%mem,comm --sort=-%cpu
By accessing the kernel's /proc hierarchy directly, the
ps command provides a lightweight, dependency-free method
to diagnose system bottlenecks, identify unresponsive programs, and
verify security permissions across all running processes.