Pkill Command in Linux operating system

Pkill Command in Linux

The Pkill is a command-line utility that is basically used to send signals to the processes of a running program in your Linux system. Basically the Pkill command is a part of the procps package which is pre-installed on all latest Linux distributions.

In this article we are going to show you how to use Pkill Command in Linux opperating system. If you want to learn about pkill command in Linux then this post is ideal for you.

Linux is an operating system, like Windows OS, iOS, and Mac OS. Linux is one of the most popular operating system on the planet, Android is also powered by Linux OS(operating system). An operating system is software that manages all hardware resources associated with desktop or laptop. In simple words, the OS(operating system) manages communication between software and hardware.

Linux OS(operating system) is also distributed under an open source license. Open source following these points :

  • Freely to run the program, for any purpose.
  • Free to study how the program works.
  • Freely to re-distribute copies so you can help your friends.
  • Free to distribute copies of your modified versions to others.

How to Use the pkill Command

In the Linux, the basic syntax of the pkill command is show as below:

pkill [OPTIONS] [PATTERN]

[PATTERN] –  is specified by extended regular expressions.

When you run the above pkill command without any option then it sends the 15 (TERM) signal to the Process IDs of all running programs in your Linux that match with the given name in command.

For an example, to stop all Google Chrome processes, simply run the below command:

$ pkill -9 google-chrome

Above command returns 0 when there at least one running process matched with the given name. Otherwise, the exit code is 1.

You can list of all available signals in the Linux using kill -l command.

The most commonly used signals in Linux :

  • 1 (HUP): it is used to reload a process.
  • 9 (KILL): it is used to kill a process.
  • 15 (TERM): it is used to gracefully stop a process.

These signals are specified in three different ways:

  • using a number (e.g. -1)
  • with the “SIG” prefix (e.g. -SIGHUP)
  • without the “SIG” prefix (e.g. -HUP)

For an example, if you want  to reload the Nginx processes then run the below command:

$ pkill -HUP nginx

If you want to send a signal to the a processes which names are exactly as the given search pattern, then run the below command:

$ pkill '^ssh$'

The caret (^) character matches at the beginning of the string, and the dollar $ at the end.

The pkill command matches the process name by default. You can use -f option to match against full argument lists.

$ pkill -9 -f "ping 7.7.7.7"

Use -u option with pkill command to match processes that is run by a specified user:

$ pkill -u mkk

Specify the multiple users by using below command :

$ pkill -u mkk,kumar

To combine options and search patterns, run the below command :

$ pkill -9 -u mkk gnome

When you run the above command, it send KILL signal all processes that run under mkk user and contains gnome in their names.


Use the -n option to get most recent and -o for oldest started process :

$ pkill -9 -n screen
$ pkill -9 -o screen

That’s all

If you face any error and issue in above steps , please use comment box below to report.

If our tutorials helped you, please consider buying us a coffee. We appreciate your support!

Thank you for your support.

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top