Skip to content

Instantly share code, notes, and snippets.

@islander
Last active November 11, 2019 02:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save islander/06e0f23fea857de31c266f5d2bdd071f to your computer and use it in GitHub Desktop.
Save islander/06e0f23fea857de31c266f5d2bdd071f to your computer and use it in GitHub Desktop.
Linux SysRq examples
#!/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
#!/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