The ps command in Unix is used to display information about active processes. It provides details on running processes, including process ID (PID), memory usage, CPU usage, and more, useful for monitoring system performance and managing running tasks.
>Synopsis
ps [-aux | -ef | -u | -e | -f ...]
>Options
aux
Shows detailed information about all processes, including memory and CPU usage for each user.
Example:
-zsh
> ps aux
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 0.1 22580 2284 ? Ss 13:21 0:00 /sbin/init
john 1032 1.2 1.0 159644 19320 ? Ssl 13:21 0:30 /usr/bin/python3 my_script.py
-ef
Displays every process in a hierarchical structure, useful for understanding parent-child relationships.
Example:
-zsh
> ps -ef
UID PID PPID C STIME TTY TIME CMD
root 1 0 0 13:21 ? 00:00:00 /sbin/init
john 1032 1 0 13:21 ? 00:00:30 /usr/bin/python3 my_script.py
-u [username]
Restricts the display to processes owned by a specific user.
Example:
-zsh
> ps -u john
PID TTY TIME CMD
1032 ? 00:00:30 /usr/bin/python3 my_script.py