Tuesday, January 10, 2017

How to kill a process on Ubuntu


Sometimes there are programs (usually in graphical mode) that seems not responding when you try to close it, or sometimes there are program that's running on the background that we don't even know it's running, the question is how to close these annoying stuff?

Technically you can close/shutdown/terminate/kill any running program or process on ubuntu, whether is background process or graphical GUI app, we can close those things from the command line, no problem.

To close/shutdown/terminate/kill running program or process on ubuntu we can use the 'kill' command. But to be able to use 'kill' command, we need to know the process id (PID) of the program that we are going to kill.

There is another command line tool for getting the process id (PID) called 'pidof', let's say currently firefox is running, to get the process id of firefox, you run 'pidof firefox' on the command line.
pidof [program/process name]
Example:
pidof firefox
If the process/program indeed running, pidof will output process id (PID), the PID could be more than one, if pidof doesn't output anything that means the program/process is not running or you enter the wrong name.

Once you get the process id (PID), it's time to kill it!
sudo kill -9 [PID]
Example:
sudo kill -9 3575


No comments:

Post a Comment