I spent a wonderful evening recently with some friends looking at old servers and fixing database reports. I know... I really need to get out more.
During the course of the evening Gene showed us how to force a reboot or shutdown by using the SysRq key and a combination of other keys which were as follows...
Hold down the "Alt"
As intrigued as I was, I noticed that the screen went black like we were back in terminal mode and I saw a flood of information on the screen and I knew that each of these letters stood for something. After doing a little bit of research online I found the following chart that may help if you need to use the "Magic System Request" in Linux.
0 - 9 - sets the console log level, controlling which kernel messages will be printed to your console so that you don't get flooded.
B - restarts the system without making steps to ensure that the conditions are good for a safe reboot, using this key alone is like doing a cold reboot.
E - sends SIGTERM to all processes except init. This means that an attempt is done to end the current processes except init, safely, e.g. saving a document.
F - call oom_kill(Out Of Memory Killer), which will kill a process that is consuming all available memory.
H - displays help about the SysRq keys on a terminal though in actuality you can use any key except for the ones specified, to display help.
I - sends SIGKILL to all processes except init. This means that all the processes except for init are killed, any data in processes that are killed will be lost.
K - kills all processes on the current terminal. It is a bad idea to do this on a console where X is running as the GUI will stop and you can't see what you type, so you will need to switch to a tty after doing the magic SysRq.
L - sends SIGKILL to all processes, including init. This means that every process including init will be killed, using this key will render your system non-functional and no further magicSysRq keys can be used. So in this case you will have to cold reboot it.
M - dumps memory info to your console.
O - shuts down the system via ACPI or in older systems, APM. As in key "B", using this key alone is like a cold reboot(Or in this case, a cold shutdown).
P - dumps the current registers and flags to your console.
Q - dumps all timers info to your console.
R - takes keyboard and mouse control from the X server. This can be useful if the X-Server crashed, you can change to a console and kill the X-Server or check the error log.
NOTE:- The documentation refers to this key's task as "Turns off keyboard raw mode and sets it to XLATE", but I suppose it's safe enough to assume that it takes back control from X.
S - writes all data from the disc cache to the hard-discs, it is a sync and is necessary to reduce the chances of data corruption.
T - dumps a list of current tasks and info to your console.
U - remounts all mounted filesystems read-only. After using this key, you can reboot the system with Alt+SysRq+B without harming the system.
W - dumps uninterruptable (blocked) state tasks.
Remember that although you can use these letters in any sequence that you wish, there may be unforeseen consequences by skipping some of the letters in the REISU* sequence and skipping straight to the B or O so be careful when using these commands. Also remember that there is a build in reboot or shutdown procedure and it is better to use that then the forced commands with the magic system request keys.