ps
Overview
The ps
command displays information about active processes running on the system. It provides a snapshot of the current processes.
Syntax
ps [options]
Common Options
Option | Description |
---|---|
-e |
Show all processes |
-f |
Full format listing |
-l |
Long format |
-u username |
Show processes for specified username |
aux |
Show all processes in BSD format |
-C cmdname |
Select by command name |
--sort |
Sort by specified criteria |
Key Use Cases
- Monitor system processes
- Troubleshoot performance issues
- Find resource-intensive processes
- Check process status and details
Examples with Explanations
Example 1: Show all processes
ps -ef
Shows all processes in full format
Example 2: Show process tree
ps -ejH
Displays process hierarchy in a tree format
Example 3: Show processes by user
ps -u username
Shows processes owned by specified user
Understanding Output
Standard columns in ps output: - PID: Process ID - TTY: Terminal type - TIME: CPU time used - CMD: Command name - %CPU: CPU usage - %MEM: Memory usage - VSZ: Virtual memory size - RSS: Resident set size
Common Usage Patterns
Find all processes using a lot of CPU:
ps aux --sort=-%cpu
Find process by name:
ps -C processname
Show process hierarchy:
ps -ejH
Performance Analysis
- Use
ps
withtop
orhtop
for real-time monitoring - Combine with
grep
to filter specific processes - Use sorting options to identify resource-intensive processes