ps command
ps (Process Status)
Purpose
ps command is used to display information about the currently running processes on a system.Basic Syntax
If used without any options, ps displays only the processes running in the current terminal session.
Common Examples
1. Basic Usage
Output Example:
Explanation:
-
PID: Process ID — unique number assigned to each process
-
TTY: Terminal type (e.g., pts/0 → pseudo terminal)
-
TIME: Total CPU time used by the process
-
CMD: Command that started the process
2. View All Processes
or
Shows all processes running on the system (not just your terminal).
3. Detailed Information
Output Example:
Additional columns:
-
UID: User who owns the process
-
PPID: Parent Process ID (which process started this one)
-
C: CPU utilization percentage
-
STIME: Start time of the process
4. All Processes in Full Format
or
Displays a snapshot of all processes with full details.
Difference between the two:
-
ps -ef→ System V style output -
ps aux→ BSD style output
Example:
Key columns:
-
%CPU: CPU usage percentage
-
%MEM: Memory usage percentage
-
VSZ: Virtual memory size
-
RSS: Resident Set Size (actual physical memory used)
-
STAT: Process state (e.g., S=sleeping, R=running, Z=zombie, T=stopped)
5. View Process Tree
Displays processes in a hierarchical tree structure showing parent-child relationships.
6. Search for a Specific Process
Shows only processes related to a particular program or keyword (here, “firefox”).
7. Display Processes for a Specific User
Lists all processes owned by the given user.
8. Show Process IDs Only
Example:
Outputs only the PID(s) of processes named "firefox".
🧾 Process States (STAT column)
| Symbol | Meaning |
|---|---|
| R | Running |
| S | Sleeping |
| D | Uninterruptible sleep (usually I/O) |
| T | Stopped by job control signal |
| Z | Zombie (terminated but not cleaned up) |
💡 Tips
-
The
pscommand provides a snapshot of processes — it does not update continuously. -
For continuous monitoring, use
toporhtop. -
Combine
pswithgrepto search specific processes efficiently.
Program to try
simple and useful shell script that uses the ps command to display the top 5 processes consuming the most CPU and memory.
🧩 Script: process_report.sh
Comments
Post a Comment