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:
htop
can't do it? You can send SIGKILL to kill any hanging process you have rights to. – val - disappointed in SE Aug 01 '19 at 10:23