Last active
November 11, 2019 02:51
-
-
Save islander/06e0f23fea857de31c266f5d2bdd071f to your computer and use it in GitHub Desktop.
Linux SysRq examples
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Remount all filesystems read-only | |
echo "sync disks." | |
echo s > /proc/sysrq-trigger | |
sleep 2 | |
echo "remount all read-only." | |
echo u > /proc/sysrq-trigger |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
options=() | |
options[0]="disable every SysRq function." | |
options[1]="enable every SysRq function." | |
options[2]="enable control of console logging level" | |
options[4]="enable control of keyboard (SAK, unraw)" | |
options[8]="enable debugging dumps of processes etc." | |
options[16]="enable sync command" | |
options[32]="enable remount read-only" | |
options[64]="enable signalling of processes (term, kill, oom-kill)" | |
options[128]="allow reboot/poweroff" | |
options[256]="allow nicing of all RT tasks" | |
echo "Enabled SysRq options:" | |
for i in $(seq 1 8); do | |
(( ($(</proc/sys/kernel/sysrq) & $((1<<$i))) > 0 )) && echo -e "$((1<<$i))\t${options[$((1<<$i))]}" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment