How to reset your Linux machine using script

If you want to reset the Linux machine, just like when you press the reset button then you need to use the SysRq method. As per wikipedia , “The magic SysRq key is a key combination understood by the Linux kernel, which allows the user to perform various low-level commands regardless of the system’s state. It is often used to recover from freezes, or to reboot a computer without corrupting the file system.” We normally use a key combination, but it is also possible to do the same operation by using /proc/sysrq-trigger effectively.


But before doing anything, we need to enable that feature using the below method.

echo "1" > /proc/sys/kernel/sysrq

#or add permanently by adding an entry to /etc/sysctl.conf:
kernel.sysrq = 1
echo b > /proc/sysrq-trigger
echo s > /proc/sysrq-trigger
echo c> /proc/sysrq-trigger

For more information check this out.

Leave a Reply

Your email address will not be published. Required fields are marked *