ps Cheatsheet
Quick reference for listing and filtering processes with ps in Linux
The `ps` command displays process information in Linux. This cheatsheet covers common output formats, filtering patterns, sorting, and practical process-inspection commands.
Basic Syntax
Core ps command forms.
| Command | Description |
|---|---|
ps | Show processes in the current shell |
ps -e | Show all running processes |
ps -f | Show full-format output |
ps aux | BSD-style all-process listing with user and resource info |
ps -ef | SysV-style all-process listing |
List Processes
Common process listing commands.
| Command | Description |
|---|---|
ps -e | List all processes |
ps -ef | Full process list with PPID and start time |
ps aux | Detailed list including CPU and memory usage |
ps -u username | Processes owned by a specific user |
ps -p 1234 | Show one process by PID |
Select and Filter
Filter output to specific process groups.
| Command | Description |
|---|---|
ps -C nginx | Match processes by command name |
ps -p 1234,5678 | Show multiple PIDs |
ps -u root -U root | Show processes by effective and real user |
ps -t pts/0 | Show processes attached to a terminal |
ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%cpu | Custom output sorted by CPU |
Custom Output Columns
Show only the process fields you need.
| Command | Description |
|---|---|
ps -eo pid,cmd | PID and command |
ps -eo user,pid,%cpu,%mem,cmd | User, PID, CPU, memory, command |
ps -eo pid,lstart,cmd | PID with full start time |
ps -o pid= -o comm= | Output without column headers |
ps -p 1234 -o pid,ppid,user,%cpu,%mem,cmd | Custom fields for one PID |
Process Tree and Parent/Child
Inspect process hierarchy.
| Command | Description |
|---|---|
ps -ejH | Hierarchical process view |
ps -axjf | Forest view (BSD style) |
ps -o pid,ppid,cmd -p 1234 | Parent-child context for one process |
ps -eo pid,ppid,cmd --sort=ppid | Group processes by parent PID |
Useful Patterns
Common real-world combinations.
| Command | Description |
|---|---|
ps aux | grep nginx | Quick process search (includes grep line) |
ps -C nginx -o pid,cmd | Cleaner command-name search without grep |
ps -eo pid,%cpu,%mem,cmd --sort=-%mem | head | Top memory consumers |
ps -eo pid,%cpu,cmd --sort=-%cpu | head | Top CPU consumers |
ps -ef | grep -v grep | grep sshd | Legacy grep pipeline pattern |
Troubleshooting
Quick checks for common ps usage issues.
| Issue | Check |
|---|---|
| Command not visible in output | Use ps -ef or ps aux for full list |
| Process disappears between checks | It may be short-lived; sample repeatedly or use watch |
grep shows itself | Use ps -C name or pgrep instead of raw grep |
| Missing expected process details | Add fields with -o (for example %cpu, %mem, lstart) |
| Need exact process ID for kill | Use ps -C name -o pid= or pgrep name |
Related Guides
Use these guides for full process-management workflows.
| Guide | Description |
|---|---|
Ps Command in Linux | Full ps guide with examples |
Kill Command in Linux | Terminate processes by PID |
Pkill Command in Linux | Kill processes by name/pattern |
Pgrep Command in Linux | Find process IDs by name and pattern |
How to Kill a Process in Linux | Practical process-stop workflow |