This quick tutorial teaches you to kill a process in Linux using its process id. This is particularly helpful in killing unresponsive programs.
You can easily stop a program in Linux terminal by pressing the Ctrl+C keys. But it often happens that you need to ‘kill’ an unresponsive program. In Windows you have the task manager for this situation. You can use task manager in Linux as well but the command line way is a lot better and effective in handling unresponsive programs.
Using the terminal is better because GUI based tools may not show the still running hidden process. GUI tools may not be available if you are using the server edition of a Linux system.
How to kill a process in Linux
If you run an application, it runs some process in the background. If you want to close this application forcefully, you can kill the process associated to it.
To kill a process, you need to know the its process ID (PID). The next section tells you how to find the process ID of a program.
Step 1: Find the process ID (PID) of the program
There are several ways you can use for finding the PID of a process.
If you know the name of the process, you can use the command pidof in this fashion:
pidof <program_name>
You can take help of the tab completion to find the name of the program. The good thing about this command is that it will give the PID of all the processes initiated by the program. Here’s an example:
pidof slack
9734 9718 9716 9708 9622 9619
If the pidof command doesn’t result anything, it could mean either there is no process running of that program or the program name you used is incorrect.
If you are unaware of the exact program name, you can try the ps command. This ps command is used for seeing the running processes on the system. You can use the grep command with the program name (or whatever you remember about it).
ps aux | grep -i “name of your desired program”
ps aux command returns all the running process on the system. And the grep afterwards shows the line which matches with the program name. The output of the command will be like this:

As shown in the picture above, you can get the process ID of the program/process in the second column. Just ignore the line with “–color =auto”.
Step 2: Kill the process using the PID
Once you have the PID of the desired application, use the following command to kill the process:
sudo kill -9 process_id
If you have more than one process id, you can kill all of them together by providing all the PIDs.
sudo kill -9 process_id_1 process_id_2 process_id_3
You can also combine the kill command the pidof command to kill all the process of a program.
sudo kill -9 `pidof programe_name`
Of course, you have to replace the program_name with the name of the program you want to kill.
Bonus Tip: Use killall to kill all the process of a given program
If you know the name of the program, you can use the magnificent killall command and kill all the processes of that program in one single command.
killall program_name
How do you kill programs in Linux?
I hope this quick little tutorial helped you. What is your favorite way to kill a program in Linux? Task manager, kill, killall or xkill?
Are there no systemd commands for this?
kill -9 is rather drastic – you might need to use it sometimes, but often kill -TERM is enough and actually better (it allows the killed process to clean up properly) – kill -9 is like pulling the plug.
I’ve been dealing with my computer locking up, as in completely locking up, no response. It could be due to a myriad of things. Is there an equivalent to control-alt-delete in linux?
There is task manager but if your system is frozen up and nothing moves, it won’t work. You should try and investigate why the problem occurred? Was it some process, overheating or something else.
Hi Nicolas, some distributions disable Ctrl-Alt-Del but usually it works as expected, just not in some GUI contexts. What often works is going to a text console with Ctrl-Alt-F3 and then Ctrl-Alt-Del (instead of F3, you might/can use any of the other F# function keys)
Thanks Bart,
I think I might be having a hardware problem, probably the video card. The box locks up and sometimes the monitor is pixelated or color distorted with no way to launch or access anything GUI-wise.
I might try to make swap bigger, get more ram and an extra HD.
Thanks you
some processes will trigger itself, after killing it, what should I do sir? thanks
Example, please? If they are service or daemons, they should be disabled using systemd commands.