ps
Overview
The ps
command displays information about active processes. It provides a snapshot of current processes and their status.
Syntax
ps [options]
Common Options
Option | Description |
---|---|
-e |
All processes |
-f |
Full format |
-l |
Long format |
-u user |
User processes |
-p pid |
Process ID |
-C cmd |
Command name |
-o format |
Output format |
--sort key |
Sort output |
-H |
Process hierarchy |
-L |
Thread info |
-m |
Memory info |
aux |
BSD style |
Output Fields
Field | Description |
---|---|
PID | Process ID |
PPID | Parent PID |
%CPU | CPU usage |
%MEM | Memory usage |
VSZ | Virtual size |
RSS | Resident size |
TTY | Terminal |
STAT | Process state |
START | Start time |
TIME | CPU time |
COMMAND | Command line |
Key Use Cases
- Process monitoring
- Resource usage
- System analysis
- Troubleshooting
- Performance tuning
Examples with Explanations
Example 1: All Processes
ps -ef
Full process list
Example 2: Process Tree
ps -ejH
Show process hierarchy
Example 3: Custom Format
ps -eo pid,ppid,cmd
Select output fields
Common Usage Patterns
User processes:
ps -u username
Sort by memory:
ps aux --sort=-%mem
Process search:
ps -C processname
Process States
State | Description |
---|---|
R | Running |
S | Sleeping |
D | Uninterruptible |
Z | Zombie |
T | Stopped |
W | Paging |
X | Dead |
< | High priority |
N | Low priority |
Additional Resources
Best Practices
- Use filters
- Check resources
- Monitor states
- Regular checks
- Document findings
Security Considerations
- Process visibility
- User permissions
- System impact
- Information leak
- Resource usage
Troubleshooting
- Missing processes
- High resource use
- Zombie processes
- State issues
- Performance problems
Common Formats
- Default
- BSD style
- System V
- Custom
- Thread view