Friday, January 7, 2022

[SOLVED] Write permission denied with sudo

Issue

I want to write to a protected file as root at startup. Just using

echo "disable" > /sys/firmware/acpi/interrupts/gpe6F

as a user (or even with sudo in front) does of course not work. So I looked around, but the suggested alternatives don't work either, e.g. the tee trick does not work:

echo "disable" | sudo tee /sys/firmware/acpi/interrupts/gpe6f
tee: /sys/firmware/acpi/interrupts/gpe6f: Permission denied

and neither does this:

sudo sh -c "echo \"disable\" > /sys/firmware/acpi/interrupts/gpe6f"
sh: 1: cannot create /sys/firmware/acpi/interrupts/gpe6f: Permission denied

I can only succesfully write to that file when I change to root:

sudo su
echo "disable" > /sys/firmware/acpi/interrupts/gpe6F

This one works. However, I want to do this at system startup via /etc/rc.local. That file should be executed as root already. So I put the above mentioned commands (without sudo) in /etc/rc.local and ran sudo /etc/rc.local to test it and got "Permission denied" errors. What am I missing here?

In case you are interested in my motivation to do this: [solved] ASRock skylake flooding syslog with gpe6F


Solution

As tripleee and ESYSCODER have pointed out: Changing gpe6f to gpe6F fixed the problem for me. What a stupid little mistake.

Thanks! :)



Answered By - mad