Linux Kill Process by PID: Kill any Process With Single Command

Linux Kill Process by PID: Kill any Process With Single Command

You can already know when we can use any operating system in some useless programs running in the background. These programs can easily be closed on your Linux desktop, but we can get confused on the Linux server. Sometimes we cannot close the unusable programs on the hosting server, and this is harmful to our server. In this case, we can use PID to close the running programs. Today's topic is how to kill a Linux process by PID. Before killing any process through PID, we need to know some basic information about PID.

PID

PID is basically used to identify the value of the process ID. You can run this on your Linux server to define any process's identification number.

Here, I can provide some basic and most useful PID numbers for action processes. In PID No. 1, we use it to kill the systemd and init progress on the Linux operating system, and PID No. 9 is the default use for killing any process.

Find the Process id of Running Program

Now, we can start to find the progress ID of any software and kill this program with the PID command. For example, we need to close Firefox in the Linux operating system with the PID command. First, you can run Firefox in the background on the Linux operating system. After running Firefox, open the terminal on the Linux operating system and put the following command to find the PID of Firefox:

pgrep firefox
Command for Finding The Progress ID

In my case Firefox Progress id is 47456. Now we can kill this Software using Kill Command.

Linux Kill Process by PID

Now We can Kill the Progress with the PID. ou will see the PID code in the terminal. Our next and final step to stop any program with PID is to put the following command:

sudo kill -9 Processa_ID

Here, -9 is used to force kill any program without getting any type of error. Now, we need to kill (force stop) Firefox, and we know that the Firefox process ID is 47456. Then put the given command to stop Firefox:

sudo kill -9 47456
kill the firefox with Process ID

Here, you will see that Firefox is successfully closed on the Linux operating system.

Thanks for reading this content and spending your time on my website. If you would like to receive more notifications about this type of blog post, you can click on the subscribe button to get email newsletters.