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 -efShows all processes in full format
Example 2: Show process tree
ps -ejHDisplays process hierarchy in a tree format
Example 3: Show processes by user
ps -u usernameShows 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=-%cpuFind process by name:
ps -C processnameShow process hierarchy:
ps -ejH
Performance Analysis
- Use
pswithtoporhtopfor real-time monitoring - Combine with
grepto filter specific processes - Use sorting options to identify resource-intensive processes