How to kill a process in Linux - kill, killall, pkill, xkill

When Linux is usually stable, sometimes a process just wants to mess up and hangs around unwelcomely. It just ignores your request to close up. And here are the 4 killer (literally) commands you can use to show who is the real boss when the aforementioned case happens:

kill

This command is used to send the termination signal to a process or a process group on the system, referenced by their numeric process IDs (PIDs). For the signals, either the signal name or signal number can be used. To find the PID of the process, you can use the "pidof" command. For example, to find the pid of the caja file manager, I use this command:
 pidof caja  

And here is the output:


After finding out the PID of the process, to kill it, say firefox, the command is:
 kill 2443  

Note: You can also find the PID of the processes by using "top" or "ps", but "pidof" is the easiest IMO.

killall

The "killall" command is actually more convenient to use than "kill" since you dont have to find out the PID of the process. All you need is the name of the process, say caja, and then run this command:
 killall caja  

pkill

In case you're a lazy guy who doesnt want to type out the whole name of a process, like chromium-browser, the "pkill" command will be very helpful for you. "pkill" kills a process by its name but unlike "killall", you just need a part of the name here. For example, to kill Chromium browser, you can use either:
 pkill chro  

or
 pkill ium  

or
 pkill romi  

Basically, this "pkill" command will kill any process whose name contains "chro" or "ium" or "romi" ... So be careful when using "pkill" though, you surely should not try to kill chromium-browser by using:
 pkill c  

xkill

This command can only be used in the X Windows system. When you run this command, your cursor will transform into the "x" letter and you just need to left click on a process to kill it. After the process is killed, the "x" letter will become the normal cursor again.
linux tips and tricks