The ps Command
ps (process status) shows you what's running. It's the foundation of process management.
Basic ps
By default, ps only shows processes in your current terminal. Not very useful.
The Magic Flags: ps aux
ps aux shows ALL processes from ALL users. This is what you'll use 99% of the time.
Understanding the Output
| Column | Meaning |
|---|---|
| USER | Process owner |
| PID | Process ID |
| %CPU | CPU usage |
| %MEM | Memory usage |
| VSZ | Virtual memory (KB) |
| RSS | Physical memory (KB) |
| TTY | Terminal (? = no terminal) |
| STAT | State (R, S, T, Z, etc.) |
| START | Start time |
| TIME | CPU time used |
| COMMAND | Command that started process |
Process States in STAT
The STAT column has modifiers:
| Letter | Meaning |
|---|---|
| R | Running |
| S | Sleeping (interruptible) |
| D | Sleeping (uninterruptible, usually I/O) |
| T | Stopped |
| Z | Zombie |
< | High priority |
| N | Low priority |
| s | Session leader |
| l | Multi-threaded |
+ | Foreground process |
Finding Specific Processes
Avoid grep Showing Itself
grep nginx might show itself in results. Use:
ps aux | grep [n]ginx
The brackets prevent grep from matching its own process.
Alternative Syntax: ps -ef
BSD style (ps aux) vs Unix style (ps -ef):
-ef shows PPID (parent PID), which aux doesn't.
Useful ps Combinations
Show Process Tree
The f flag shows forest (tree) format.
Show Only Your Processes
Sort by CPU
Sort by Memory
What does `ps aux | grep nginx` do?
Quick Reference
| Command | Shows |
|---|---|
ps | Your terminal's processes |
ps aux | All processes, all users |
ps -ef | All processes with parent PID |
ps auxf | Process tree |
ps aux --sort=-%cpu | Sorted by CPU |
ps aux --sort=-%mem | Sorted by memory |
Key Takeaways
ps auxis your go-to for viewing processes- Use
grepto filter for specific processes - STAT column shows process state (R, S, T, Z)
ps -efshows parent PIDps auxfshows tree structure
Next: real-time process monitoring with top and htop.