Viewing Processes (ps)
The ps command shows information about running processes. It's essential for monitoring what's running on your system.
Basic Usage
ps
Understanding Processes
A process is a running program. Each process has:
- PID: Process ID (unique number)
- PPID: Parent Process ID
- User: Who started it
- State: Running, sleeping, etc.
- Command: The program running
Common ps Options
| Command | Description |
|---|---|
ps | Your processes in current terminal |
ps aux | All processes, detailed |
ps -ef | All processes, full format |
ps -u user | Processes for specific user |
ps aux - The Most Useful Form
ps aux
Column Meanings
| Column | Meaning |
|---|---|
| USER | Process owner |
| PID | Process ID |
| %CPU | CPU usage |
| %MEM | Memory usage |
| VSZ | Virtual memory size |
| RSS | Resident set size |
| TTY | Terminal |
| STAT | Process state |
| START | Start time |
| TIME | CPU time used |
| COMMAND | Command and arguments |
Exercise: View All Processes
Use ps aux to see all running processes:
Process States
The STAT column shows process state:
| Code | State |
|---|---|
| R | Running |
| S | Sleeping |
| D | Uninterruptible sleep |
| T | Stopped |
| Z | Zombie |
Filtering Processes
With grep
ps aux | grep python
ps aux | grep nginx
ps aux | grep -v grep # Exclude grep itself
For Specific User
ps -u root
ps -u $(whoami)
Useful ps Commands
Tree View
ps auxf # Forest format (shows hierarchy)
pstree # Process tree
By Memory/CPU
ps aux --sort=-%mem | head # Top memory users
ps aux --sort=-%cpu | head # Top CPU users
Custom Columns
ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%mem
Exercise: Find a Specific Process
Find all bash processes:
ps vs top
| Feature | ps | top |
|---|---|---|
| Output | Snapshot | Real-time |
| Interactive | No | Yes |
| Best for | Scripting | Monitoring |
Key Takeaways
psshows running processes- Use
ps auxfor all processes with details - Filter with
grepto find specific processes - PID is the unique process identifier
- STAT shows process state (Running, Sleeping, etc.)

