ps (Process Status)
The ps command stands for Process Status. It is used to display information about the processes currently running on the system. Unlike top, which provides a dynamic real-time view, ps provides a static snapshot of processes at the moment the command is executed.
1. Basic Usage
ps [options]
- Running
pswithout any options lists only the processes associated with the current terminal session.
2. Common Option Combinations
| Option | Description |
|---|---|
aux |
BSD Style. Displays all running processes from all users with detailed info. |
-ef |
Standard Style. Displays all processes in a full-listing format. |
-u [user] |
Lists processes owned by a specific user. |
-p [PID] |
Shows information for a specific Process ID only. |
3. Practical Examples
① Viewing All System Processes (The Standard Way)
ps aux
# Columns: USER, PID, %CPU, %MEM, VSZ (Virtual Size), RSS (Actual Memory), STAT (Status), etc.
② Checking if a Specific Program is Running (with grep)
This is the most frequent use case. For example, to find 'nginx' related processes:
ps aux | grep nginx
③ Viewing Processes in a Tree Format
ps -axjf
4. [Tip] Decoding the Process Status (STAT)
Common codes found in the STAT column:
* R (Running): Currently running or on the run queue.
* S (Sleeping): Interruptible sleep (waiting for an event to complete).
* D (Uninterruptible sleep): Waiting for I/O (usually disk I/O).
* Z (Zombie): Terminated process but not yet reaped by its parent.