25

Recently when I tried to open a video with VLC, my system slowed down, the open applications webbrowser, VLC and filemanager and others didn't react any longer. The mouse just reacted still very slowly.

On a windows machine i would press a keycombi CTRL-ALT-DEL to open the taskmanager, search the process which caused the hang and kill it.

Since i'm fairly new with the use of linux i haven't figured out the best practice for solve such a situation in Ubuntu.

Which quick and effective way would you recommend to identify the hanging process and close it, when the system already reacts very slowly on user input?

5 Answers 5

34

There are two primary ways to identify hung processes. One is via the System Monitor GUI and the other is via top in command-line.

System Monitor

This can be found in System > Administration

account

You can also create a keyboard shortcut for this in this article.

Once the GUI launches you can select the Processes tab which will list all the running processes. Sort by the CPU column to find the most CPU intensive task

cpu

Lastly you can right click that task and choose to end it, stop it, or kill it. Killing it will immediately stop and remove that process from the system.

kill

Command-Line

If you have a terminal open you can simply type top this will list all the running processes similar to that of the Processes tab in the GUI

top

Within top it is CPU sorted by default - so the top most CPU intensive tasks are at the top. At anytime you can press the letter k to kill a process

k

Simply type the PID of the process you wish to kill and press enter. It will ask for a Kill signal to send. To kill the process nicely use the default 15 - to kill it right away "Do not pass go, do not collect $200" use 9.

sigkill

The process will then be terminated.

If you are experiencing sluggish interface you can try to SSH in remotely if that is enabled - or switch to a virtual console via Ctrl+Alt+F# Where F# is a Function Key (F3, F4, F5, etc). To return to the Desktop environment switch to either F7 or F8 depending on your version of Ubuntu.

4
  • 5
    Great answer. I usually assign the CTRL+ESC shortcut to the System Monitor. This gives me a quick access to kill process. Jan 3, 2011 at 17:02
  • 1
    +1 for System Monitor. It could kill/stop a hanging VLC process, which htop could'nt do.
    – malisokan
    Aug 31, 2014 at 20:48
  • @malisokan Are you sure htop can't do it? You can send SIGKILL to kill any hanging process you have rights to. Aug 1, 2019 at 10:23
  • Debian to turn back to desktop Ctrl+Alt+F7
    – 0xFK
    Oct 5, 2021 at 2:23
4

Add the System Monitor applet to your panel (right click on the panel, select Add to Pannel and search for System Monitor) the and right click on it to open the System Monitor application.

You can launch the System Monitor application by pressing Alt+F2 and start the program gnome-system-monitor.

Go to the "Processes" tab and right click the appliction you intent to kill.

3

Most already said (I like Marco Ceppi's answer) but there also is a "Force Quit" applet you can add to your GNOME Panel. Right click on the panel and choose "Add to panel...":

alt text

This lets you quit a hanging application by simply clicking on it's window. Very fast and efficient.


When running Unity in 11.04 of course this application will no longer be available. There is a replacement project Indicator-Forceclose but it is not included in the repositories.

Alternatively we could run xkill from a terminal.

7
  • Does it only destroy window or also kill the process? Aug 1, 2019 at 10:25
  • @val it kills the process that created the window.
    – Takkat
    Aug 1, 2019 at 10:41
  • Just tested: it does not. I made a program that hangs inside GTK callback and killed it with xkill. Window disappeared, but program continued to run (or hang if you prefer). So answer is no, it may not kill the program if it is seriously stuck. Aug 1, 2019 at 11:13
  • @val naturally after your program had called another process for creating a window xkill will kill this additional process only. This is especially important to know for programs that run without an X-server but call X for windowing. Obviously, it would be impossible to kill any such program from the X server.
    – Takkat
    Aug 1, 2019 at 15:39
  • My program didn't called another process for it. I made a program which is same as any GTK application out there and made it hang. xkill doesn't affect such processes (GTK will cause exit if I'll later exit "hanging" and make it handle loss of window). GTK callbacks have nothing to do with multiprocessing. Aug 1, 2019 at 15:45
0
$ ps -el|grep ProcessName

above command list out all processes named ProcessName. then kill process with its PID.

Example. To kill vlc mediaplayer.

step 1)

$ ps -el|grep vlc

above command output somthing like : 0 S 1000 5980 2324 1 80 0 - 256647 do_sig tty2 00:00:00 vlc. Here 5980 is process id. To kill vlc media player type following command.

step 2)

$ kill -9 5980

above command will kill vlc mediaplayer.

0

A decade later--programs still hang. You would have thought they would have done something about it by now. This advice is fine for when a program is stuck, but not sucking up all of your available CPU resources--in which case you may not be able to do anything with a GUI client.

To see who is hogging your processor:

ps fu -e --sort -%cpu | head -n5

Often you don't know who is hanging up your system (e.g. with the dreaded kworker ACPI storms). You can change the -n to be however many lines, usually 5 is enough to include the init process and the top few CPU hogs.

It is best to try and kill with SIGTERM 15. Well written code will catch this, and free up memory and close files as part of destructor code. If that doesn't work, then SIGKILL 9, which cannot be caught, is fair game. Sometimes kill likes a little more, either kill -n 15 or kill -s SIGKILL as it seems that some versions don't like just the -SIGNUM. You can get a list of all the signals with kill -l. If you just type kill PID then my distro's version defaults to SIGTERM.

If your whole UI is wedged, then you probably want to CTL-ALT-F3. It might take a while, so go pour yourself a cup of coffee or let the dog out before trying something more drastic.

If that doesn't work, you might need to try and kill your XWindows server (e.g. CTL-ATL-BACKSPACE) but don't get your hopes up too high. Go make some tacos, or take the dog for a walk this time, and hopefully you will return to a log-in.

If not, then hopefully you have the Magic SysRq key set up. You probably want to take a few minutes and RTFM before you need to use this so you have an idea of what is going on.

On my computer, which uses a wireless ThinkPad keyboard (but is not a ThinkPad which may use Alt+Fn+S+), it's Alt+PrtSc+. In some cases it may depend on which Alt key you use (not on my machine, but I have read thhis has been an issue if you have R-alt and L-alt send different decodes).

First: Alt+PrtSc (or whatever your key combo is) + r all at the same time.

  • This Returns keyboard control to you.

  • Most guides will then have you send a series of commands, but there may be some other options worth trying.

  • I will try Ctrl+Alt+F1 first.

  • The "usual and customary" sequence is REIUSB

  • You have to type each with whatever your Magic SysRq key combo is

  • One of the problems that will wedge you is the bad habit of opening too many tabs in your browser and sucking up all of your memory, including swap space. Rather than change your behavior, you can just call the out of F'ing memory killer (OOM) and it will snuff Firefox (or chrome or...) e.g. ALt+PrtSc+f.

  • I have rarely had cases where the file system was frozen (and, presumably, there was a good reason for this in the first place, which is why getting up off your butt and doing something between steps is a good idea--if there was something getting fixed and needed to freeze the file system I probably want to give it a chance to flush and close things before I yank the plug) using Alt+PrtSc+j which is supposed to Just unthaw the file system and I will use this as my first step before calling the OOM, unless I have 85 open tabs in Firefox (yeah, I know, why???).

  • I have not had great results with E and I working when running XWindows. You might need to check and see if the bitmask it set to allow them.

  • You can tell Everything (except init) to quit using Alt+PrtSc+e (using SIGTERM)

  • Since you probably finished your coffee, maybe time for a bathroom break. Give it a few minutes to work. If your processor is stuck it might take a while for this command to make it through the various buffers and acted on.

  • If that does not do the trick, then you can repeat it with SIGKILL with Alt+PrtSc+i

  • When that has not worked for me in the past, I have found that Killing everything with Alt+PrtSc+k has worked, and ended me up with a log-in prompt. If you end up at a log-in prompt, you can continue to restart your system by Unmounting (and give it some time) and Synching your drives before your Boot up again. NOTE: the sync hasn't taken place until you see the "OK" and "Done" appear on the screen.

  • What also has worked is then Ctl+Alt+Backspace which restarted XWindows and gave me the graphic login.

  • I have not had good luck with the options to Get my framebuffer console back or to Very nicely ask to get my framebuffer back.

Other useful guides:

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .