In Linux, you can use the kill
and killall
commands to force kill a process.
Using kill
:
ps
command to list all running processes and their process IDs. For example:ps aux
kill
command to send a signal to the process to terminate it. The -9
option is used to send the SIGKILL signal, which forcibly terminates the process. For example:kill -9 12345
Replace 12345
with the actual process ID of the process you want to kill.
Using killall
:
ps
command to list all running processes and their names. For example:ps aux
killall
command to kill all processes with the specified name. For example:killall process_name
Replace process_name
with the actual name of the process you want to kill.
Note: Use these commands with caution, as forcibly killing a process can cause data loss or corruption. It is usually better to try to terminate the process gracefully using the
kill
command with a different signal, such asSIGINT
(-2
) orSIGTERM
(-15
). Consult the documentation and online resources available for more information on the various signals that can be used with thekill
command.