Linux kill Command Tutorial

The process is the core part of an operating system where jobs or tasks are completed by the processes. Processes run for single or multiple tasks to complete or serve for a long time. Killing processes is an action to end processes and stop it. The process can be killed in different ways with different methods. In this tutorial, we will examine how to list and kill processes in Linux distributions like Ubuntu, Debian, Mint, Kali CentOS, Fedora, RHEL, etc.

List Running Processes

Processes generally identified with their process name or process ID. In order to kill a process generally their identifiers name and PID are used. So first we will list running processes with their related information by using different command.

First and the most popular command is the ps command which will list running processes. We will also provide the aux parameters to the ps command in order to list all processes with their related information.

$ ps aux

top command is a popular command which can be used to monitor running processes and resource usage. top command can be also used to list processes. top also provides a filter mechanism for the processes according to their names.

$ top

Filter and List Process According Its Name

In order to kill processes we should provide its process ID or name but using process ID is the most reliable way. Because killing process by name create conflicts where a similar name or the same name different processes can be killed. We have described ps and top commands to get process name or process ID but as you see there will be a lot of output. We can use the grep command in order to filter the process ID accordingly. In the following example, we will grep or filter the apache2 process by using the grep command.

$ ps aux | grep apache

List Process ID with pidof Command

Linux also provides the pidof command which will search for a given process and print its process ID. We will just provides the process name and all realted process IDs will be printed.

$ pidof firefox

Kill Process with PID

We can use the kill command in order to kill a process. The kill command has the following syntax where we should provide the process ID or PID. Alternatively, we can provide some options for different signals.


In the following example we will kill the process with its process ID 32060.

$ kill 32060

When the provided process is killed successfully there will be no output in the console. If there is a problem some warning or error will be printed to the console. For example, if the process is owned by other user and we do not have the required permissions the Operation not permitted error will be printed.

Kill Multiple Processes

kill command can be used to kill multiple process in a single execution. We will just provide the multiple process IDs by delimiting them with spaces.

$ kill 123 2345 1234

Kill Process with top Command

The top command can be also used to kill the process. First, we will run the top command which will list currently running processes. Then we will press the k key which is the kill short form. We will be asked for the PID or process ID. Just type the process ID you want to kill and press Enter key.

Send Signal To Process with kill Command

Processes use signals in order to communicate with each other and the operating system. Actually killing processes will send the SIGHUP signal to the process. There are also different signals which can be used to kill a process in an elegant way. kill command with the -l option will list signals and their values.

$ kill -l

Kill Process Forcibly

A process can be killed forcibly without any precaution and restrictions. A process generally killed forcibly if it is not responding to normal kill signals because of internal problems or restrictions. Killing a process forcibly may cause some data loss or malfunction. You can use the -9 or -SIGKILL or -TERM signals in order to kill a process forcibly.

Kill with the -9 signal forcibly.

$ kill -9 1907

Kill the process with the -SIGKILL signal forcibly.

$ kill -SIGKILL 1907

Kill the process with the -SIGINT signal which is equal to the CTRL+C keyboard shortcut.

$ kill -SIGINT 1907

Kill the process with the -SIGTERM signal forcibly. This will stop the process gracefully.

$ kill -SIGTERM 1907

Leave a Comment