how to kill process in Linux

Windows Articles

How To Configure Slave BIND DNS Server On Ubuntu 20.04

In our previous guide we covered the setup of Master(Primary) DNS Server. Here we'll learn that how to configure slave bind dns server on...

Install Fossil on Linux – An alternative to Git

Hello, friends. In this post, we will talk about a serious alternative to Git. In a few words, we'll show you how to install...

How to backup and restore BCD in Windows 10

Hi! Boot Configuration Data (BCD) is a set of data where the system boot information is stored. In addition, from there the operating systems...

How To Install and Configure Master BIND DNS Server On Ubuntu 20.04

Today we are going to learn that how to install and configure Master BIND DNS server on Ubuntu 20.04. As you all know that...

Diskpart is a very useful tool for managing storage in Windows 10.

Hello! Diskpart is an internal tool included in Windows systems that allows you to manage storage units. Indeed, it is possible to manage internal...
Muhammad Nabeel
Muhammad Nabeel
Network and System Administrator

A process is the instance of a computer program that is being executed by one or many threads. It contains the program code and its activity. Several processes may be associated with the same program; for example, opening up several instances of the same program often results in more than one process being executed.

kill is a command which is used in several popular operating systems to send signals to running processes. In Linux kill command is normally used to terminate running process. In this article we will cover basics of kill command so you will understand it and apply it in your environment.

Before killing or terminating any process we have to get its process ID (PID) or process name. We can use wo commands to find process ID’s, first is “ps” command and the second it “top” command. In this article we will use ps command to find a process ID and its name.

Locate process using ps command

ps command is used to see processes, following command to list all running processes.

ps aux

a: Show processes for all users
u: Display the user who is using the process
x: Show all processes. (it also show the processes running in a GUI environment)

kill process in Linux

List specific process ID

If you want to search any specific process so you can use any of following three methods.

Method 1:

ps -aux | grep process-name

e.g check for Apache process

ps -aux | grep httpd

kill process in Linux

You can see process id’s of Apache in above image.

Method 2: Use pidof command

pidof httpd

Sample outputs:

4372 4371 4370 4369 4368 4361

kill process in Linux

Method 3: Use pgrep command

pgrep httpd

kill process in Linux

All above methods will show process ID’s of httpd (Apache) process.

Kill Process

kill command is use to terminate or kill running processes.

Method 1: Kill process by its process ID

Now, I will kill one Apache process using its process ID.

kill -9 4372

Then, verify that PID is killed

pidof httpd

kill process in Linux

So you can see in above image that process 4372 is no more exist.

Method 2: Kill process by its name

If you want to kill all the processes of a service you can use this method.

kill -9 httpd

OR

pkill httpd

Now, verify process is killed.

pidof httpd

Then, you will see that all processes of httpd will no more exist.

Kill all processes of a User

You can use below command to show processes of a user.

ps -fu user-name

Now you will get process ID’s of that user. E.g I show process ID’s of user “osradar” in below image

kill process in Linux

Then, run below command to kill all processes of the user

kill -HUP process-ids

kill user in Linux

So, when you run again below command you will see no result.

ps -fu user-name

That’s it, You now know that how to kill running processes in Linux.

More articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest article

How To Configure Slave BIND DNS Server On Ubuntu 20.04

In our previous guide we covered the setup of Master(Primary) DNS Server. Here we'll learn that how to configure slave bind dns server on...

Install Fossil on Linux – An alternative to Git

Hello, friends. In this post, we will talk about a serious alternative to Git. In a few words, we'll show you how to install...

How to backup and restore BCD in Windows 10

Hi! Boot Configuration Data (BCD) is a set of data where the system boot information is stored. In addition, from there the operating systems...

How To Install and Configure Master BIND DNS Server On Ubuntu 20.04

Today we are going to learn that how to install and configure Master BIND DNS server on Ubuntu 20.04. As you all know that...

Diskpart is a very useful tool for managing storage in Windows 10.

Hello! Diskpart is an internal tool included in Windows systems that allows you to manage storage units. Indeed, it is possible to manage internal...
x