Christophe CasalegnoAutoimmune warrior, Entrepreneur & Bio/Hacker

brain@127.0.0.1:~$ cat post.html

« Hard » reboot of a Linux server from a shell

Sometimes an unstable dedicated server can make it impossible to use the reboot command. For example, corrupted binaries, a damaged filesystem, or simply a system load that leaves you without enough control. In that case, if you are physically at the server, you can use SysReq. But these key combinations can be a problem remotely, when your only access is an SSH shell.

Fortunately, you can still get the same result. This is an « abrupt » reboot: the services are not stopped, and the machine is rebooted, with a result similar to a hard reboot. You could also set up a cron job on the server to carry out this rescue operation under certain conditions (be careful to check every parameter properly).

Anyway, let us get to the point:

From your Linux shell, simply run the following commands:

echo 1 > /proc/sys/kernel/sysrq (to activate the sysreq)
echo b > /proc/sysrq-trigger (to trigger the abrupt reboot)

Unlike the reboot or shutdown command, the restart is automatic, without trying to stop processes or to unmount the file systems (which also avoids reboots that cannot work because of these problems). A little Hacker trick, but still one to use sparingly!

Christophe Casalegno
​You can follow me on: Twitter | Facebook | Linkedin | Telegram | Youtube

3 comments

  1. Ce que l’on peut raisonnablement se demander, c’est pourquoi ce truc n’est pas dans tous les manuels…

Leave a comment

Add a comment
Christophe Casalegno Brain 0verride

Keep it simple
and direct!