Emergency Debian Commands when the computer crashes to try and save it Emergency Debian Commands when the computer crashes to try and save it

December 9, 2022

bash debian

I have an old laptop that often crashes when i use it. I was taking a backup of the files on it, but it seemed to hang a lot and became unresponsive so I wanted to write a blog post about how to prevent holding the power key to turn it off and to turn it off without pulling the plug.

It seemed to be caused by the mariadb and redis servers, which I killed with the commands

systemctl stop mariadb
systemctl stop redis

If you force the machine to turn off, it risks rebooting into an error and having to run 'fsck' to fix it, which isnt something I want to do, so I wanted to document how to turn it off without holding down the power key.

The first option I use is to login to a virtual console. You can get to these with Ctrl+Alt+F1 to F6. Ctrl+Alt+F7 is the console where your X server is running, So to get back into your GUI window manager: type:

Ctrl+Alt+F7 (or sometimes Alt+F7 or Ctrl+Alt+F8) 

now in a terminal, i can login as the root user and shutdown the machine with

shutdown now

When you are in these 6 consoles you can press Alt+RightArrow or Alt+LeftArrow to move to next/previous console respectively. I think you can also return to it with the command 'chvt 7'

In this console, you can often login as root and type the command 'top' to see what is causing the problem, Mine is often the mysql db on this machine going beserk and maxing out the CPU. You can often type 'shutdown now' to naturally turn off the machine.

If this doesnt work, the next option is the REISUB – R E I S U B key strokes. Here you press ALT + PrintScreen + R then wait a few seconds, followed by ALT + PrintScreen + E, ALT + PrintScreen + I, ALT + PrintScreen + S, ALT + PrintScreen + U and finally ALT + PrintScreen + B will reboot the machine as if you had held the power button down for 6-10 seconds.

Each key does a task as mentioned below

unRaw      (take control of keyboard back from X),
 tErminate (send SIGTERM to all processes, allowing them to terminate gracefully),
 kIll      (send SIGKILL to all processes, forcing them to terminate immediately),
  Sync     (flush data to disk),
  Unmount  (remount all filesystems read-only),

So with a combination of these commands and key strokes, I have managed to shutdown the machine in a more gentle way.

Hope it helps.

If you would like to contact me you can either use this form on londinium.com or via Twitter @andylondon