Linux Commands and Scripts

How To Kill a Process In Linux Using Terminal

In this article, you will learn how to kill a process in Linux using the command line.

Sometimes processes stop performing or unexpectedly die and when you try to re-run the process again, you may get an error of the original never truly shut down completely.
In such a case, you need to kill the process using the command line.

You can kill the process in multiple ways. We have covered some of it in this article.

There are different signals that can be sent to both kill commands. We can use a signal to kill a process with names and numbers.
To find out the signal’s name and number, run the following command:

kill -l

Here you can find a list of signals. There are 3 signals, we’ve covered.

SIGKILL – 9 – Forcefully close

SIGTERM – 15 – Termination signal

SIGSTOP – 19 – Stop the process

Let’s get started.

1)

Find the process ID using ps command:

ps aux | grep [process name]

To kill the process:

kill -9 (–SIGKILL) [PID]

2)

Find the process ID using the top command:

top

To kill the process

type k enter

type PID enter

Now type signal. By default, the signal set to 15/sigterm. You can change it or use it by entering

The process is killed.

3)

Find the process ID using the pgrep command.
Here you need to know the process name to find the process ID. If you don’t know the process name, you need to use a different way to find the process ID.

pgrep [process name]

To kill the process

kill -9 (–SIGKILL) [PID]

4)

Find the process ID using jobs command:

jobs

You will get the job ID of the process. We will use that job ID to kill the process.

To kill the process:

kill %1 [1 is a job ID]

After the % symbol, you need to mention the job ID.

[Need assistance to fix this error? We’ll help you.]

Now, you have learned to kill a process using the command line. There are also different commands to kill the process. In this article, we’ve mentioned some of the commands to kill the process.

Today, we saw how our Support Engineers fix this error.

Related Articles