Randomly Freezes - How Can I Diagnose the Problem? [duplicate]
All operating systems freeze sometimes, and Ubuntu is no exception. What should I do to regain control when...
- just one program stops responding?
- nothing at all responds to mouse clicks or key presses?
- the mouse stops moving entirely?
- I have an Intel Bay Trail CPU?
In what order should I try various solutions before deciding to pull the power plug?
What should I do when starting up Ubuntu fails? Is there a diagnostic procedure I can follow?
If it locks up completely, you can REISUB it, which is a safer alternative to just cold rebooting the computer.
REISUB by:
While holding Alt and the SysReq (Print Screen) keys, type REISUB.
R: Switch to XLATE mode
E: Send Terminate signal to all processes except for init
I: Send Kill signal to all processes except for init
S: Sync all mounted file-systems
U: Remount file-systems as read-only
B: Reboot
Some mnemonics for REISUB:
- Rise up (from the dead) if you're inclined to zombie movies
- BUSIER backwards, as in The System is busier than it should be!
- Reboot Even If System Utterly Broken.
- Or the classic: Raising Elephants Is So Utterly Boring
This is the SysReq key:
NOTE: There exists less radical way than rebooting the whole system. If SysReq key works, you can kill processes one-by-one using Alt+SysReq+F. Kernel will kill the mostly «expensive» process each time. If you want to kill all processes for one console, you can issue Alt+SysReq+K.
NOTE: You should explicitly enable these key combinations. Ubuntu ships with sysrq default setting 176 (128+32+16), which allows to run only SUB part of REISUB combination. You can change it to 1 (all commands enabled) or 244 which is potentially less harmful. To do this:
sudo nano /etc/sysctl.d/10-magic-sysrq.conf
and switch 176 to 244; then
echo 244 | sudo tee /proc/sys/kernel/sysrq
It will immediately work! You can test this by pressing Alt+SysReq+F. For me, it killed active browser tab, then all extensions. And if you will continue, you can reach X Server restart.
More info on all the Alt+SysReq functions here.
When a single program stops working:
When a program window stops responding, you can usually stop it by clicking the X-shaped close button at the top left of the window. That will generally result in a dialog box saying that the program is not responding (but you already knew that) and presenting you with the option to kill the program or to continue to wait for it to respond.
Sometimes this does not work as expected. If you can't close a window by normal means, you can hit Alt+F2, type xkill
, and press Enter. Your mouse cursor will then turn into an X. Hover over the offending window and left-click to kill it. Right clicking will cancel and return your mouse to normal.
If your program is running from a terminal, on the other hand, you can usually halt it with Ctrl+C. If not, find the name and process ID of its command, and tell the program to end as soon as possible with kill [process ID here]
. It sends the default signal SIGTERM
(15
). If all else fails, as a last resort send SIGKILL
(9
): kill -9 [process ID here]
. Note that you should only use SIGKILL
as a last resort, because the process will be terminated immediately by the kernel with no opportunity for cleanup. It does not even get the signal - it just stops to exist.
(Killing a process by kill -9
allways works if you have the permission to kill. In some special cases the process is still listed by ps
or top
(as "zombie") - in this case, the program was killed, but the process table entry is kept, becuse it's needed later.)
When the mouse stops working:
If the keyboard still works, press Alt+F2 and run gnome-terminal
(or, if these fail to launch, press Alt+Ctrl+F1 and login with your username and password). From there you can troubleshoot things. I'm not going to get into mouse troubleshooting here, as I haven't researched it. If you just want to try restarting the GUI, run sudo service lightdm restart
. This should bring down the GUI, which will then attempt to respawn, bringing you back to the login screen.
When you have an Intel Bay Trail CPU
See https://askubuntu.com/a/803649/225694.
When everything, keys and mouse and all, stop working:
First try the Magic SysReq method outlined in Phoenix' answer. If that doesn't work, press the Reset button on the computer case. If even that doesn't work, you'll just have to power-cycle the machine.
May you never reach this point.