ps (list running processes)
This command provides a list of processes running on the system. It's usually called like this:
The letters a, u and x are options for the ps command. They lack the familiar dash (-) because ps originates from the Unix-like operating system BSD, where option letters are not preceded by a dash. You'll rarely see ps used with options other than aux – they have become a kind of standard. Their meaning is as follows:
- a: List all processes that run on a terminal.
- u: Print an additional output column for the user controlling a process.
- x: List all processes without a controlling terminal.
Used together, the options a and x make ps list all processes running on the system.
You'll often use ps to find out the ID of a running process, for instance in order to terminate it using →kill. Combine ps with grep to output only the processes that match a particular search string, like so:
ps aux | grep PROCNAME
This will only show ps output lines that contain the keyword PROCNAME. You'll see this combination of ps and grep very often in all sorts of documentation. However, there's a faster way to get at the ID of a process:
pgrep -l PROCNAME
This has the same effect as the command line above, but output is restricted to process names and IDs.