Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm starting X as a user and need to set my keyboard brightness in /sys/class/leds/asus\:\:kbd_backlight/brightness. The /sys/ directory gets recreated after reboot, so the permissions will reset too. How do I set it up so I don't need to make the file writable by all users after every boot?

I'm using Archlinux with SDDM as the login manager and KDE as DE.

share|improve this question
You could put a command in a systemd boot service. – goldilocks Mar 23 '13 at 13:52
Are you meaning to create a own systemd service which set the permissions? Or do you talk from a specific file? – Timo Mar 23 '13 at 14:04
The former. "Service" is the systemd term, even though in this case it would just be a one-off command and not a daemon. You could make it a kind of "miscellaneous stuff" service like rc.local is under sysV. In this case the service just runs a shell script, and you put the command in there. – goldilocks Mar 23 '13 at 14:31
up vote 6 down vote accepted

No you can't, the permission of sysfs is defined in kernel space and can't be changed with userspace tools (unless with kernel side support).

But for your own problem, you could setup a sudo entry that allow everyone to write to that path, i.e ALL ALL = (ALL) NOPASSWD: /usr/bin/tee /sys/class/leds/asus\:\:kbd_backlight/brightness

And when you write to that directory, use a script like this, echo 1 | sudo /usr/bin/tee "/sys/class/leds/asus::kbd_backlight/brightness"

share|improve this answer
I tried that, but it asks always for the password. I also tried to add a NOPASSWD: behind the (ALL). – Timo Mar 29 '13 at 16:19
@Timo can you try again? See my updates – warl0ck Mar 29 '13 at 22:55
It works now. The problem was that my entry was overwritten by another one without NOPASSWD. And i accepted your answer because it was easier as the other answers. Thanks all. – Timo Mar 30 '13 at 18:24
I am using linux Mint Debian in sony vaio and trying to create a file in /sys/devices/platform/sony-laptop/kbd_backlight to control the keyboard Backlight. I have changed the path in your code which leads to this error: bash: syntax error near unexpected token ('` The command I typed is ALL ALL = (ALL) NOPASSWD: /usr/bin/tee /sys/devices/platform/sony-laptop/kbd_backlight Please help – Indra Jun 14 '14 at 14:00
I couldn't get this working on an Ubuntu machine until I added a comma between /usr/bin/tee and /sys/class.... After a brief look at the grammar in man sudoers I suspect the comma is necessary. – Jake Mitchell May 2 '15 at 0:23

The /sys directory in Linux is fake, it is a view into the kernel dressed up as files. So to change permissions in it permanently means hackig the kernel, and that would be ill-advised. As the comments say, perhaps a systemd unit setting this would be a solution (in general, set the change up as part of the boot process).

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.