The ps command in Linux is a fundamental tool for viewing and managing processes directly from the terminal. With practical examples, users can quickly monitor resource usage, troubleshoot issues, and control applications running on the system.
This guide presents 9 practical examples of the ps command, explaining key options, real scenarios, and common workflows for both everyday use and advanced debugging.
| Command | Description | Use Case | Typical Output Fields |
|---|---|---|---|
| ps aux | Show detailed information for all processes | Get a full snapshot of system activity | USER, PID, %CPU, %MEM, VSZ, RSS, TTY, STAT, START, TIME, COMMAND |
| ps -ef | Display full-format process listing | View process hierarchy with PPID | UID, PID, PPID, C, STIME, TTY, TIME, CMD |
| ps -p PID | Show information for a specific process ID | Inspect a single process in detail | PID, TTY, TIME, CMD |
| ps -u USER | List processes owned by a specific user | Audit or limit view to one user’s processes | USER, PID, %CPU, MEM, VSZ, RSS, STAT, COMMAND |
Process Listing Basics with ps
Display all processes for the current user
Using ps without options shows only processes tied to the current terminal session. This basic view helps identify active tasks without system-wide noise, making it ideal for quick checks.
Show detailed info for all processes
The ps aux command lists every process on the system with resource usage details. It is a go-to command for system monitoring, helping you see CPU and memory consumption at a glance.
Filter and Search Processes
Search by process ID
The ps -p PID option focuses on a single process, providing key details like status, elapsed time, and command used. This targeted approach is helpful for scripts and troubleshooting specific services.
Filter by user
With ps -u USER, you can review only the processes belonging to a specific account. This is useful in multi-user environments to monitor activity, enforce limits, or debug permission-related issues.
Process Control and Signals
Send signals to processes
ps outputs the PID, which you can use with kill to send signals such as SIGTERM or SIGKILL. Controlling processes in this way allows graceful restarts, pauses, or forced terminations when necessary.
Key Takeaways and Recommended Workflows
- Start with ps aux for a comprehensive overview of system processes
- Use ps -p to inspect individual processes by PID quickly
- Filter output with ps -u to manage multi-user environments
- Pipe ps results to grep, watch, or sort for more powerful monitoring
- Leverage PID values from ps when sending signals with kill
FAQ
Reader questions
How do I find the PID of a specific process using ps?
Pipe the output of ps aux to grep with the process name, for example: ps aux | grep nginx. This filters the list so you can quickly locate the PID associated with your target process.
Can ps show the full command line with arguments?
Yes, ps aux or ps -ef both display the complete command line including arguments, helping you understand how a process was started and which options are in use.
How can I monitor process resource usage over time?
Combine ps with tools like watch, for example: watch -n 1 'ps aux --sort=-%cpu | head', to refresh the process list periodically and observe changing CPU and memory usage.
What is the difference between ps -ef and ps aux?
ps aux shows CPU and memory usage in percentage format, while ps -ef uses a different column layout and includes parent PIDs. Both reveal full command lines, but the choice depends on your preferred format and sorting needs.