giovedì 10 febbraio 2011

How to Kill a Running Process in Ubuntu (or any Linux distro)

So, you’ve been running Ubuntu for awhile and you’re happy with it. Everything is running smoothly. You think to yourself, this is going better than I expected. And then, out of nowhere, Firefox (or some other mischievous app) crashes. You try to reopen it, only to find this warning: “Application X is already running. Please close all versions of the application and try again.” You instinctively hit ctrl+alt+delete, only to remember that you’re not in Microsoftland anymore. How exactly do you kill a running process in Ubuntu?
Upon first glance, killing a process in Ubuntu may seem frightening. Rest assured that it is not. There are a few different methods for killing a process–in fact, you can even set up a ctrl/alt/delete sequence–but by far the easiest is to simply open the terminal and type one simple line. It literally takes less than ten seconds.

Step 1: Open the Terminal by navigating to Applications > Accessories > Terminal. Type: ps aux and press enter.
A long series of processes will appear in your Terminal. 

process1
click for full size image
Step 2: Scroll through the processes and look for the application you want to kill. If you’re logged in as a user, scroll down past the ‘root’ processes and into the processes running under your username. Look at the end of the lines for the name of the applications. For example, if you need to kill Firefox, look for ‘usr/lib/firefox’ at the end of a line.

Step 3: Once you find that process, look at the very front of the line. You will see something like “username 23873 6.8…..” It’s the number right after the username you need–in this case, 23873. That is the process number.
process2
click for full size image

Step 4: Now, to simply kill that process, type: sudo kill -9 process number (replaced ‘process number’ with the actual number) and then press enter. 

process3

The process will be shut down. Close the Terminal and restart the application.

2 commenti: