Over the years there have been certain commands that have really helped me out of a bind. One of those commands is the ps command. The ps stands for process status and it tells you, as you would expect, the status of a process. This is a fast way to know if an application or command is running on a Linux system. Oh sure you could fire up a swell GUI for the same purpose, but that GUI does you no good if you are working on a headless server installation or working on a remote machine. In those instances the ps command is your best bet for helping to manage processes.
You will be glad to know that the ps command will most certainly be already installed on your Linux machine, so there is no need to worry about installation.
The basic command structure for ps is:
Of course every good Linux command offers a lot of options, and ps is no exception. For this command we will just outline the best groupings of options together instead of just listing all of (or the best) options. This way you can skip right down to the command you need to use.
Show list of processes owned by a specific user
Say I want to list all processes owned by user jlwallen. To do this I could enter one of two commands:
This will list out all processes that are owned by the user issuing the command. The results for this command will look like:
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
jlwallen 560 0.0 0.3 18312 7376 ? SNs 19:40 0:00 /etc/alternativ
jlwallen 561 0.0 0.1 7316 3932 pts/0 SNs 19:40 0:00 bash
jlwallen 1137 0.0 0.0 1644 416 ? S 19:47 0:00 sleep 8
jlwallen 1141 0.0 0.0 1644 420 ? S 19:47 0:00 sleep 8
jlwallen 1142 0.0 0.0 4384 1012 pts/0 RN+ 19:48 0:00 ps ux
You can also get a similar listing with the command:
ps U jlwallen
The results of this command will be:
PID TTY STAT TIME COMMAND
560 ? SNs 0:00 /etc/alternatives/x-terminal-emulator
561 pts/0 SNs 0:00 bash
1223 ? S 0:00 sleep 8
1227 ? S 0:00 sleep 8
1228 pts/0 RN+ 0:00 ps U jlwallen
Show all processes
To see every process on your system you would enter the command:
The results of this command would look similar to that of ps ux only it would show the process of every user as well as the system.
List the details of a single process
What about when you want to see the details of only a single process? Imagine issuing the command ps ux and having to search through all of the listings to find the information about the one process you are trying to gain information about. Say, for example, you need to find the PID (Process ID) of the currently running daemon for Dansguardian. You can use the ps command and pipe the results to the grep command to search the listing for a specific string and print out only the matching strings. To do this issue the command:
ps aux | grep dansguardian
which will print out something like:
113 2596 0.0 0.5 17852 11460 ? Ss 06:49 0:00 /usr/sbin/dansguardian
Now you can see the PID of Dansguardian is 2596. You can kill this with the kill 2956 command.
There are many more uses for the ps command as well as many more ways to use the ps command. The above three examples are the most often used, but don't think you are limited to only those uses. Issue the command man ps and you will see a full listing of all the ps options available to you.
Advertising revenue is falling fast across the Internet, and independently-run sites like Ghacks are hit hardest by it. The advertising model in its current form is coming to an end, and we have to find other ways to continue operating this site.
We are committed to keeping our content free and independent, which means no paywalls, no sponsored posts, no annoying ad formats or subscription fees.
If you like our content, and would like to help, please consider making a contribution:
Ghacks is a technology news blog that was founded in 2005 by Martin Brinkmann. It has since then become one of the most popular tech news sites on the Internet with five authors and regular contributions from freelance writers.