How to kill processes with GUIs

How to kill processes with GUIs


One of the things I hate about Windows is that there is no good way to kill frozen processes. Theoretically, you type Ctrl-Alt-Delete, wait for Task Manager to pop up, and kill the process. But in reality, the process doesn't always die immediately (it usually takes multiple tries and a very long time). GNU/Linux users don't have this problem. Here's how to end processes using the terminal, a few GUIs, and even a first person shooter.

Killing processes in the terminal

The terminal (also known as the command line) is the most powerful tool for virtually any job. So let's look at how to kill processes with it. First, open your favorite terminal program (konsole for KDE, gnome-terminal for Gnome, and xterm are some good ones). Then, type ps -A (not ps -a). This gives you a listing of all the programs currently running and their PID. To kill a program, type kill PIDHERE, replacing PIDHERE with the PID of the program as shown by ps. See figure 1 for an example. Note that sometimes you will get error messages when trying to kill a program. If you do, you must kill the program as root (sudo kill PIDHERE or su and then kill PIDHERE depending on the operating system).

Figure 1: Killing Pidgin using ps and kill in xtermFigure 1: Killing Pidgin using ps and kill in xterm

Often, the searching through ps's output is like searching for a semi-colon in a 5MB source file. Luckily, if you know the name of the program, it's easy to find it. Instead of typing ps -a, type ps -A | grep NAMEHERE, replacing NAMEHERE with the string you want to find. For example, if I typed ps -A | grep fire, all the processes with the string fire in them would be listed. You can also add the -i flag to grep (so you'd type ps -A | grep -i fire) to make the search string case insensitive.

Killing processes with GUIs

Both KDE and Gnome provide their users with GUIs for killing processes. In KDE, run KSysGuard (many distributions also use Ctrl-Esc). Just click on the tab, "ProcessTable", select the item, and click "Kill". In Gnome, open System Monitor (aka Gnome System Monitor), select the "Processes" tab, select the item, and hit "End Process". If you can't kill the process, try running the KSysGuard or Gnome System Monitor as root (see previous paragraph for more).

If you just want to kill an inactive window without having to dig up a PID or running a bloated GUI, there's an option called xkill. Just open a terminal, and type xkill. Click on a window, and it will be killed (right-click to cancel). KDE users can also type Ctrl-Alt-Esc to bring up xkill.

A bonus: killing processes and having fun

If you really want to "kill" a process, then you need to try psDooM (figure 2). Download (make sure it isn't a patch, but a source or a binary) and install it, copy an IWAD (Freedoom has a few available) into wherever you installed psDooM (usually /usr/local/games/psdoom), and then run one of the executables located in the folder. Now, when you get mad at the world, all you have to do is open up a Microsoft product in WINE, and then shoot it.

Figure 2: Literally killing processes in psDooMFigure 2: Literally killing processes in psDooM

Conclusion

You now know how to kill a process with the terminal, kill a process with KSysGuard, Gnome System Monitor, or xkill, and even shoot a process! Next time a Microsoft user complains about his system freezing, all you have to do is grin and show him GNU/Linux.

Category: 

Comments

undefined's picture
Submitted by undefined on

may i recommend pgrep and pkill over ps, grep, and kill.

by example:

$ pgrep init
1
5521
$ pgrep -l init
1 init
5521 xinit
$ pgrep -fl init
1 init [2]
5521 xinit /etc/X11/xinit/xinitrc -- /usr/bin/X :0 -nolisten tcp -layout Dual -auth /home/user/.serverauth.5500
$ pgrep -l ^init
1 init

pkill works similarly:

$ sleep 1m &
[1] 1662
$ pkill sleep
[1]+ Terminated sleep 1m
$ sleep 1m &
[1] 2224
$ pkill -KILL sleep
[1]+ Killed sleep 1m
$ sleep 1m &
[1] 1764
$ pkill 1m
$ pkill -f 1m
[1]+ Terminated sleep 1m

they should already be installed on debian (as the procps package has a priority of "required") and ubuntu (as with my wife's default install).

undefined's picture
Submitted by undefined on

i actually have nothing to technically add to the parent comment, but the editing of it brings up an interesting point: what are the editorial policies of fsm, specifically regarding user posts?

because i was subscribed to this thread i saw the original post before it was edited and approved by the editor (by way of an emailed "thread subscription update"). while i did not find the original language offensive, i did find the conveyed attitude appalling.

though the single removed word wasn't particularly offensive to me, why not edit out the word and show the edits (eg "ps -A | grep is [not as powerful]")? that would show the community what exactly was edited unlike the current ominous note ("Edited for language, Admin"). or remove the entire post, maybe notifying the original author by email if they have an account (so they can repost a more appropriate comment if so desired).

and what garners an edit? profanity? poor attitude?

just curious as i considered myself a member of a very similar community (based on a linux publication) until an editor removed his own inflammatory post and denied both the post and the removal. that's not an "open" community i want to be part of, so i left.

heck, will this post be removed because i dare question the editors? ;)

Tony Mobily's picture

Hi,

The post contained useful information, but showed poor attitude.
I found the original language offensive. The trouble is, that person wasn't logged in.
I made the decision that guarantee the spread of (relatively valuable) information, didn't sneakily change comment's contents (I hate that), and respected the poster.

To me, poor attitude is even indirectly call somebody "stupid" - especially if you don't even have an account.

Please note that since we receive a number of comments, we often need to decide quickly - or we would spend the best parts of our days discussing whether a word means "A" or "B" :-D

We very, very, very rarely delete comments (it only happened once, actually) and very occasionally we edit them.

Bye!

Merc.

mykeyspace's picture
Submitted by mykeyspace on

Great article. You gotta love the doom thing. This really shows how creativity in the free software world can thrive, because this would never be included in a commercial product.

One honorable mention: if you're in top (e.g. to look which processes use a lot of memory/cpu) you can kill an application by hitting "k" and typing in the PID. See man top or press "?" whilst in top for more info.

Thanks for letting me now about pdDooM (not that i'll ever use it, i kinda like the stability of my system).

clievers's picture
Submitted by clievers on

This sounds good. I'll have to give the pgrep & pkill a try. Sometimes I've run into areas where I cannot seem to kill a process. Perhaps these two will help.

------
let's all play nice!

Andrew Min's picture
Submitted by Andrew Min on

If you can't kill a process, try killing it as root (sudo pkill instead of just pkill).

--
Andrew Min

Nuno Silva's picture
Submitted by Nuno Silva on

If you don't get an “Operation not permitted” error, and the process is not killed, you may try sending a SIGKILL:

kill -9 PID or kill -KILL PID

The difference is that applications can handle TERM the way they want (some may even save opened files, emails, &c before being closed), but no process can ignore a KILL signal.

That's, no alive process. When a process is already dead (zombie, defunct), it can't answer the signal.

Anonymous visitor's picture
Submitted by Anonymous visitor (not verified) on

Hmm... I would have guesed that killall command would have been mentioned here. I never use kill but killall every second day.

For example:
killall gnome-panel
or
killall nautilus
are too commands that come handy when tweaking Gnome desktop, and especially if something goes wrong and you end up with a broken gnome-session.

And, no need to know any cryptic process id numbers either, just type killall "processname" and you're done.

Lord AGNUcius's picture

My favorite is htop.sf.net

It runs in the console (ncurses); is light, fast and feature rich.

Now I just need to figure out how to bind Ctrl-Shift-ESC (as in NT/2k/XP) to launch it.

There are also ATComputing.nl/Tools/atop and csincock.customer.netspace.net.au/blahps.htm, but I haven't tried them.

Dugster's picture
Submitted by Dugster on

There is always a solution.Thanx to all who add info which helps me!!

Anonymous visitor's picture
Submitted by Anonymous visitor (not verified) on

Hi,

I accidentally ran firefox it was not responding so I knew I had to kill the process and I did it once through the system monitor, well the following day when it happened again I accidentially hit the "hide process" and now and every time I turn the computer I can not see firefox on the system monitor. How do I enable it so that it would show as running on the system monitor again.

undefined's picture
Submitted by undefined on

i presume you are talking about gnome-system-monitor as it has the functionality you describe (though so could kde, but i wouldn't know).

in gnome-system-monitor (2.14.5, gnome 2.14) select the menu item View -> Hidden Processes (or Ctrl-P). select firefox from the list of hidden processes, press the "Remove From List" button, and press the Close button.

Author information

Andrew Min's picture

Biography

/ˈændruː/ /mi:n/
(n): a Christian.
(n): a student.
(n): a technology enthusiast.
(n): a journalist for several online publications.

Andrew Min is a student, programmer, and journalist from New York City.

My main forte in the technology realm is journalism. I’ve written for a variety of magazines, both print and non-print, with a focus on open source software and the new web. I’ve also been interviewed on a long list of topics, ranging from politicians on Twitter to open source software and homeschooling.

I also have experience with a variety of programming languages (Bash, Batch, CSS, JavaScript, PHP, and (X)HTML) and content management systems (WordPress). I’ve been hired to design and administer several websites. In addition, I’ve been the lead programmer on several small coding projects.

Most forwarded

Interview with Dave Mohyla, of DTIDATA

Dave Mohyla is the president and founder of dtidata.com, a hard drive recovery facility based in Tampa, Florida.

TM: Where are you based? What does your company do?
DTI Data recovery is based in South Pasadena, Florida which is a suburb of Tampa. We have been here for over 10 years. We operate a bio-metrically secured class 100 clean room where we perform hard drive recovery on all types of hard disks, from laptop hard drives to multi drive RAID systems.

Anybody up to writing good directory software?

Since the very beginning, directories (of any kind) have had a very central role in the internet. (I have recently grown fond of Free Web Directory. Even Slashdot can be considered a directory: a collection of great news and invaluable user-generated comments. As far as software is concerned, doing a quick search on Google about software directories will return the free (as in freedom) software directories like Savannah, SourceForge, Freshmeat and so on, followed by shareware and freeware sites such as FileBuzz, PCWin Download Center and All Freeware (great if you're looking for shareware and freeware, but definitely less comprehensive than their free-as-in-freedom counterparts).

Interview with Mark Shuttleworth

Mark Shuttleworth is the founder of Thawte, the first Certification Authority to sell public SSL certificates. After selling Thawte to Verisign, Mark moved on to training as an astronaut in Russia and visiting space. Once he got back he founded Ubuntu, the leading GNU/Linux distribution. He agreed on releasing a quick interview to Free Software Magazine.

Is better education the key to finding better software?

I read David Jonathon's article Anybody Up To Writing Good Directory Software? the other day, which got me thinking about software directories in general. As David mentioned, many of the software directories one finds when doing a quick google search are free as in beer, not as in freedom. But what interests me is the software directories that already exist, providing a combination of both free as in beer software, and open source software. Sites such as Freeware Downloads and Shareware Download don't advertise themselves as providing free as in liberty software, but each of them have a good selection of open source software available... if you know where to look.

Most emailed

Free Open Document label templates

If you’ve ever spent hours at work doing mailings, cursed your printer for printing outside the lines on your labels, or moaned “There has got to be a better way to do this,” here’s the solution you’ve been looking for. Working smarter, not harder! Worldlabel.com, a manufacture of labels offers Open Office / Libre Office labels templates for downloading in ODF format which will save you time, effort, and (if you want) make really cool-looking labels

Creating a user-centric site in Drupal

A little while ago, while talking in the #drupal mailing list, I showed my latest creation to one of the core developers there. His reaction was "Wow, I am always surprised what people use Drupal for". His surprise is somehow justified: I did create a site for a bunch of entertainers in Perth, a company set to use Drupal to take over the world with Entertainers.Biz.

Update: since writing this article, I have updated the system so that the whole booking process happens online. I will update the article accordingly!

So, why, why do people and companies develop free software?

More and more people are discovering free software. Many people only do so after weeks, or even months, of using it. I wonder, for example, how many Firefox users actually know how free Firefox really is—many of them realise that you can get it for free, but find it hard to believe that anybody can modify it and even redistribute it legally.

When the discovery is made, the first instinct is to ask: why do they do it? Programming is hard work. Even though most (if not all) programmers are driven by their higher-than-normal IQs and their amazing passion for solving problems, it’s still hard to understand why so many of them would donate so much of their time to creating something that they can’t really show off to anybody but their colleagues or geek friends.

Sure, anybody can buy laptops, and just program. No need to get a full-on lab or spend thousands of dollars in equipment. But... is that the full story?

Fun articles

Santa Claus - the most successful open source project

It dawned on me the other day, as I was shopping for the dozens of gifts it seems I have to buy every December, that Santa Claus is the most successful open source project in history. (Bridget @ Illiterarty would agree with that). Santa Claus is essentially a marketing development that is embodied by everyone who stuffs a sock, gives a gift, hosts a dinner or wishes Merry Christmas over the holiday season.

Most emailed

Editorial

When I first started thinking about Free Software Magazine, I was feeling enthusiastic about the dream. I had Dave, Gianluca, and Alan willing to help me, I had established members of the free software community willing to help me out, I had writers volunteering their time and energy for free, and I had a generous offer from OpenHosting for servers, all before I'd proved myself. There was a sense of excitement in the air, and I thought maybe, just maybe, I could make this work.

Free Software Magazine uses Apollo project management software and CRM for its everyday activities!