ps

ps displays information about a selection of the active processes.

ps [SIMPLE PROCESS SELECTION]
a
g
a, BSD-style Lists all processes with a terminal (tty).
g, List all, even session leaders, obsolete command.
ps [SIMPLE PROCESS SELECTION]
-N, –deselect
T
r
x
-N, –deselect, Select all processes except those that fulfill the specified condition. (Negates the selection)
T, Select all processes associate with this terminal.
r, Restrict the selection to only running processes.
x, List all processes owned by you.
ps [PROCESS SELECTION BY LIST]
–ppid
-q, q
–ppid pidlist, Select by parent process ID.
-q, q, –quick-pid pidlist, Select by PID (quick mode).
ps [PROCESS SELECTION BY LIST]
ps -e –forest
This command prints all processes and displays them as a tree with the –forest option.
f, –forest, ASCII art process tree.
ps -fL -C httpd
-f, Do full-format listing. This can be used with additional options to add columns.
ps [THREAD DISPLAY]
H
-L
m, -m
-T
H, Show threads as if they were processes.
-L, Show threads, possibly with LWP and NLWP columns.
m, -m, Show threads after processes.
-T, Show threads, possibly with SPID column.
ps L
L, List all format specifiers.
ps -o
-o, o, –format format, User defined format. Format is a single argument in the form of a blank separated or comma separated list, which offers a way to specify different output columns.
Example:
pid,ppid,fgroup,ni,lstart,etime
ps -p 1154 -o comm=
-o comm=, Will make the ps command display the command that this process ID is running.
ps -eo comm,etime,user | grep httpd
These commands chain together checks the time of a process.
ps –context
This displays the security context format.
watch -n 1 ‘ps -eo pid,ppid,cmd,%mem,%cpu –sort=-%mem | head’
This sequence of commands sets watch to display a list of processes routinely.