ps Flashcards
ps
ps displays information about a selection of the active processes.
ps [SIMPLE PROCESS SELECTION]
a
- A, -e
- a
- d
g
a, BSD-style Lists all processes with a terminal (tty).
- A, -e, Select all processes.
- a, Select all processes except both session leaders and processes not associated with a terminal.
- d, Select all processes except session leaders.
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]
- C
- G
- g
- p, p, -123, 123
–ppid
-q, q
- C cmdlist, Select by command name.
- G, –Group grplist, Select by real group ID (RGID) or name.
- g, –group grplist, Select by effective group ID (EGID) or name.
- p, p, -123, 123, –pid pidlist, Select by process ID.
–ppid pidlist, Select by parent process ID.
-q, q, –quick-pid pidlist, Select by PID (quick mode).
ps [PROCESS SELECTION BY LIST]
- s
- t, t
- u, U
- U
- s, –sid sesslist, Select by session ID.
- t, t, –tty ttylist, Select by terminal.
- u, U, –user userlist, Select by effective user ID (EUID) or name.
- U, –User userlist, Select by real user ID (RUID) or name.
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.