• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • VCS
  • Interview Questions
  • Database
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

pkill Command Examples in Linux

by admin

pkill command sends any specified signal, or by default the termination signal, to processes based on a matching pattern. Similar to the pgrep command, but actually sends a signal instead of printing to stdout. For example, if you start top in one terminal, and then issue pkill top in another terminal, you’ll see that top terminates. The command matched a name pattern rather than a process ID.

Syntax

The syntax of this command is:

# pkill [options] {pattern}

The kill and pkill commands send signals to processes directing them to terminate. Each signal has a number, name, and an associated event. Below are some of the most commonly used signals with their functionalities.

Number Name Description
1 SIGHUP Reload Configuration File
2 SIGINT Interrupt by keyboard (ctrl+c)
9 SIGKILL kill process
15 SIGTERM End process immediately. (Terminate a process in controlled manner so cleanup is possible)
18 SIGCONT Continue the process stopped with STOP
19 STOP Stop process
Note: However, there are processes that should not be terminated, such as the init process. Killing such processes can result in a system crash. A superuser can kill any process in the system.

pkill Command Examples

1. Kill all processes which match:

# pkill "process_name"

2. Kill all processes which match their full command instead of just the process name:

# pkill -f "command_name"

3. Force kill matching processes (can’t be blocked):

# pkill -9 "process_name"

4. Send SIGUSR1 signal to processes which match:

# pkill -USR1 "process_name"

5. Kill the main `firefox` process to close the browser:

# pkill --oldest "firefox"

6. The pkill command can be used to send a signal to processes running from a specific controlling Terminal, as shown in the following syntax:

# pkill -t [terminal_name] -U UID [command_pattern]

Filed Under: Linux

Some more articles you might also be interested in …

  1. readelf: command not found
  2. CentOS / RHEL : How to find free space in a Volume Group in LVM
  3. CentOS / RHEL : How to add a new Physical Volume to an existing Volume Group
  4. How to Limit/throttle rsync transfer speed in Linux
  5. cpufreq-aperf: command not found
  6. dpkg-query Command Examples in Linux
  7. blkdiscard Command Examples in Linux
  8. sic Command Examples in Linux
  9. CentOS / RHEL 6 : How to configure kdump
  10. Determining disk usage in Linux using “du” command

You May Also Like

Primary Sidebar

Recent Posts

  • Vanilla OS 2 Released: A New Era for Linux Enthusiasts
  • mk Command Examples
  • mixxx Command Examples
  • mix Command Examples

© 2025 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright