Skip to main content

Process Commands

killall Command Examples

The killall command helps you kill all the running instances of a process.

The killall command in Linux allows you to kill the process using the process name. Sure, you can do the same with the kill command but it requires a specific option to use the process name instead of the PID.

So in this tutorial, I will guide you through how you can get the most out of the killall command by covering the following points:

  • Syntax and available options for the killall command
  • Practical examples of the killall command

Let's start with the first one.

How to use the killall command in Linux

To use any command to its maximum potential, it is recommended to get started with the syntax and the same goes for the kill command:

killall [OPTIONS] name


  • [OPTIONS]: Optional flags (also known as options) which are used to modify the default behaviour of the killall command. For example, you can use the -I option to perform a case-insensitive search.
  • name: The name of the process which you want to terminate.

Now, let's take a look at the available options with the killall command:

Option Description
-e Require an exact match for the process name.
-I Match process names case-insensitively.
-i Interactively ask for confirmation before killing processes.
-q Suppress error messages if no processes are found.
-r Interpret the process name as a regular expression.
-s SIGNAL Specify the signal to be sent to terminate the processes (default is SIGTERM).
-u USER Kill processes owned by the specified user.
-v Report if the signal was successfully sent (verbose output).
-w Wait for all killed processes to die.

Practical examples of the killall command

In this section, I will share some helpful examples of the killall command to help you better understand the applications of the killall command.

1. Kill a specific process

By far this is the most useful application of the killall command where you append the process name to the killall command and it terminates the process.

Yes, it's that simple! Here's how you do it:

killall process-name

For example, if I want to kill htop, then I'll use the following command:

killall htop
Kill process using the killall command

2. Send a specific kill signal

By default, the killall command uses the SIGTERM termination signal which is enough for the most part but there are times when you expect different behaviour while terminating the process.

The killall command allows you to choose from multiple termination signals. To use multiple termination signals use the -S flag along with the termination signal as shown here:

killall -s <Termination_Signal> process

For example, if I want to kill the apache2 process using the SIGKILL signal, then I'll be using the following:

killall -s SIGKILL apache2

3. Kill processes interactively

You can also use the killall command to kill the process interactively which will prompt you to ask for confirmation to kill the process.

To kill process interactively, you can use the -i option as shown here:

killall -i process

For example, here, I have used the interactive prompt while killing the htop process:

killall -i htop
Kill processes interactively using the killall command

4. Kill process owned by a specific user

When you try killing a process owned by another user, it gives you an error saying "Operation not permitted":

Unable to kill process owned by another user
Unable to kill process owned by another user

To kill a process owned by a specific user, you can use the -u flag to specify the username along with the process name as shown:

sudo killall -u <username> process

For example, if I want to kill the htop process owned by the user team, then I'll use the following:

sudo killall -u team htop

5. Kill process using regular expression

If you want to kill multiple processes at once, then using a regular expression could be a great option. To use the regex, you have to use the -r flag as shown here:

kill -r REGEX

For example, If I want to terminate all processes whose names start with "http", such as "httpd" or "http-server", I'll use the following command:

killall -r 'http.*'

More ways to kill (processes)

Linux provides multiple ways you can kill processes. For example, if you want to kill a process on a specific port, then you can refer to the given guide:

Kill Process Running on a Specific Port in Linux
Want to kill the processes running on specific ports? No need to know the process ID or name. You can terminate a process based on the port number it is using.

If you are wondering about the difference between the kill and killall commands, here's your answer:

Kill vs Killall: Difference Between the Two Linux Commands
Both kill and killall commands are used for force stopping (killing) processes in Linux. Learn the difference between the two similar commands.

I hope you will find this tutorial helpful and if you have any queries, feel free to leave us a comment.

Kabir Thapar