ps is the ultimate shell tool for listing active processes on Linux and BSD systems. It may not appear that way because of the limited information you get if you just type
ps terminal, but there is much more to it thanks to a rather huge number of command line options.
ps is done and exists after making a list of the currently running processes you ask it to list, it is not a process monitor you can use to watch processes come and go. See htop, top and Comparison Of System Monitoring Programs if that is what you are looking for.
ps displays information about a selection of the active processes. If you want a repetitive update of the selection and the displayed information, use top instead.
HOWTO list all active processes
-e option can be used to make
ps list all the active processes on a machine. There is an identical
-A option for it (
-A are the exact same switch functionality-wise).
The long list of processes
-e produces can be made a bit more readable by making the output be shown as a process hierarchy. There are two output format options available that let you do that:
-H for hierarchy and
--forest. Who processes belong to are not shown by default, so you will likely want
u as well.
You can group options that require a
A process tree with all processes and the users they belong to can be shown with:
ps -e uf
Listing User Processes
All processes created by a single user can be selected with
-U followed by a user-ID in either the form of a username or a numeric ID. Your user-id is always available in the special
$UID variable. Thus;
ps -U $UID will list all of your own processes. You can add
f before or after to get a process tree. Notice that
f is not an argument with a
ps f -U $UID and
ps -U $UID f will show a process tree,
ps -fU $UID will not.
See Bash Guide for Beginners Chapter 12, Signals to your Bash shell if you want to know how to eradicate potentially unwanted processes in your process list.
ps is as good as always installed a Linux or BSD machine. It will either be part of a package called
procps-ng. You would only have to install it if you or a systems administrator deleted it accidentally or intentionally.
The ps.1 manual page is very long.
ps has a really long list of options beyond those mentioned on this page; you can look those up on the manual page.