In this blog we will be using two different Method like Kill and pkill to kill to kill a process in Linux.
Kill A Process in Linux using Command: kill
The kill command is used to send a signal to a specific process, which can be identified by its process ID (PID). To use the kill command, you must know the PID of the process that you want to terminate. You can find the PID of a process by using the ps command.
For example, the following command will show all running processes on the system:
Once you have the PID of the process you want to kill, you can use the kill command to terminate it.
The basic syntax of the command is as follows:
kill [signal] PID
For example, to kill a process with the PID of 1234, you would use the following command:
Kill A Process in Linux using Command: pkill
The pkill command works similarly to the kill command, but instead of specifying a PID, you specify the name of the process. For example, to kill all processes named “firefox”, you would use the following command:
It’s also worth noting that kill command sends a default signal SIGTERM (15) which politely asks the process to terminate, if the process is not responding to this signal, you can use kill -9 PID which sends SIGKILL (9) which forcefully kills the process.
Table of Common UNIX/Linux Signal Names and Descriptions
|1||SIGHUP||Reload Configuration File|
|2||SIGINT||Interrupt by keyboard (ctrl+c)|
|15||SIGTERM||End process immediately. (Terminate a process in controlled manner so cleanup is possible)|
|18||SIGCONT||Continue the process stopped with STOP|
In addition to these commands, there are also several GUI tools available for managing processes in Linux, such as System Monitor and htop, that allow you to view and kill processes in a more user-friendly manner.
Cong. you learned about killing a process in Linux can be done by using command-line tools such as kill and pkill and specifying the process ID or name respectively. It’s important to be careful when using these commands, as terminating the wrong process can cause data loss or system instability.