How to change kernel.sysrq to 0?

I can’t change the kernel.sysrq value.
attempt 1)
I tried:
sudo sysctl -w kernel.sysrq=0

no effect.

attempt 2)
when I edit /etc/sysctl.conf :
and add: kernel.sysrq=0
and then sudo sysctl -p
and reboot
no effect

attempt 3)
# echo kernel.sysrq=0 > /etc/sysctl.d/99-sysctl.conf
reboot
no effect.

attempt 4)
when I do:
sudo -s
sudo echo "0" > /proc/sys/kernel/sysrq

and then check if it worked:

cat /proc/sys/kernel/sysrq

output is still: 1

sudo nano /etc/sysctl.d/99-sysctl.conf

and add

kernel.sysrq = 0

I already did that, so it already says: kernel.sysrq=0

It works for me and it says so here…

https://wiki.archlinux.org/index.php/Sysctl#Configuration

But why do you want to completely disable it anyway?

Do you use sysrq_always_enabled=1 as kernel parameter?
If so remove that…

Would help to provide the current value of /proc/sys/kernel/sysrq as reference…

1 Like

attempt 5)
cat /etc/sysctl.d/sysrq.conf
output: kernel.sysrq=0

unfortunately I could not find this variable in sysctl.conf, I wish and it seems that this is enabled somewhere…

current value of /proc/sys/kernel/sysrq = 1

When I try:
$ sudo echo “0” >/proc/sys/kernel/sysrq
bash: /proc/sys/kernel/sysrq: Permission denied

first do
sudo -i

and then

echo “0” > /proc/sys/kernel/sysrq

Notice the space between > and /proc

What is the output of cat /etc/default/grub You can find the kernel parameter there if you have it.

It is not a variable, it is a kernel parameter used while providing the kernel to load in your bootloader config.
ex. in your /etc/default/grub and the like…

echo “0” | sudo tee /proc/sys/kernel/sysrq

Sorry guys, the fault was in grub.

sysrq_always_enabled=1 was in grub to load at boot. this was the culprit, I’m sorry.
I forgot about it when I put it there when I followed this tutorial:

1 Like

The reason was; I am trying to harden my setup with lynis and it gave me a warning that the kernel option kernel.sysrq needed to be 0.

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.