How to List & Kill Processes Using the PGrep & PKill Commands

The easiest way to kill processes using Linux

A screenshot of the system monitor in GNOME.


There are lots of different ways to kill processes using Linux. For instance, I previously wrote a guide showing "5 ways to kill a Linux program" and I have written a further guide called "Kill any application with a single command".

As part of the "5 ways to kill a Linux program" I introduced you to the PKill command and in this guide, I will be expanding on the usage and available switches for the PKill command.


The PKill command allows you to kill a program simply by specifying the name. For instance, if you want to kill all open terminals with the same process ID you can type the following:

pkill term

You can return a count of the number of processes killed by supplying the -c switch as follows:

pkill -c

The output will simply be the number of processes killed.

To kill all the processes for a particular user run the following command:

pkill -u

To find the effective user id for a user uses the ID command as follows:

id -u

For example:

id -u gary

You can also kill all the processes for a particular user using the real user ID as follows:

pkill -U

The real user ID is the ID of the user running the process. In most cases, it will be the same as the effective user but if the process was run using elevated privileges then the real user ID of the person running the command and the effective user will be different.

To find the real user ID use the following command.

id -ru

You can also kill all the programs in a particular group by using the following commands

pkill -g
pkill -G