How to Kill a Process Using the Linux Command Line

To kill a process in Linux, you can use the kill command. Here are the basic commands:

Using kill to Kill a Process by PID:

You need to know the PID of the process you want to kill. You can find the PID using the ps command or by using tools like htop or top. Once you have the PID, you can use the kill command as follows:

kill PID

For example, to kill a process with PID 1234, you would run:

kill 1234

By default, the kill command sends a SIGTERM signal, which asks the process to terminate gracefully. If the process doesn’t respond to SIGTERM, you can use the -9 option to forcefully terminate it:

kill -9 PID

kill -9 1234