🆔 Command: ps (Process Status)
While top and htop are like a "live video" of your system, ps is like a snapshot. It gives you a static list of the processes running at the exact moment you press Enter.
1. The "Why"
As a developer working on Project or managing your Linux environment, you often need to find the specific ID of a program to manage it or check its status in a script.
- Find a PID: You need the Process ID (PID) to kill a program that has become unresponsive.
- Scripting: You can use
psin a Bash script to check if a service (like your Supabase backend or a specific Wayland tool) is currently active. - Resource Check: See exactly what command was used to start a specific process (including all the hidden flags).
2. Basic Syntax
ps [OPTIONS]
If you type just ps, it only shows processes running in your current terminal window (which usually isn't very helpful). To see the "big picture," you need specific flags.
3. The "Standard" Flags
There are two main ways people use ps. Most Linux users memorize the "aux" combination.
| Flag | What it does |
|---|---|
| a | Shows processes for all users. |
| u | Displays the output in a "user-oriented" format (shows CPU/RAM usage). |
| x | Includes processes that aren't attached to a terminal (background services). |
The Go-To Command:
ps aux
This will output a massive list of everything running on your system.
4. Practical Examples
A. Finding a Specific Program
Because ps aux creates such a long list, we almost always "pipe" it into grep to find exactly what we want. To find your Java process for Preader:
ps aux | grep java
B. Seeing the "Tree" of Processes
If you want to see which processes are "parents" and which are "children" (e.g., which terminal started which script):
ps axjf
C. Sorting by Resource Usage
To see the top 5 processes eating your memory:
ps aux --sort=-%mem | head -n 6
D. Checking a Specific User's Processes
If you want to see only what your account (user) is running:
ps -u user
5. Understanding the Output Columns
- USER: Who owns the process.
- PID: The unique ID (essential for the
killcommand). - %CPU / %MEM: Resource usage.
- STAT: The state of the process (e.g.,
Sfor sleeping,Rfor running,Zfor zombie). - START: When the process began.
- COMMAND: The exact command that started the process.
6. Pro-Tips
pgrep: If you only need the PID of a program and don't want to deal with the fullps aux | grepmess, usepgrep:pgrep hyprland(This returns just the ID number).- Snapshot vs. Live: Use
psfor quick checks or scripts; usehtopwhen you need to watch a process's behavior over time. - Arch Linux Context: You might use
psto verify that your display manager or specific Hyprland plugins (likewaybarorswaybg) are actually running in the background after you edit your config files.