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.

  • 2
    You could put a command in a systemd boot service.
    – goldilocks
    Commented Mar 23, 2013 at 13:52
  • Are you meaning to create a own systemd service which set the permissions? Or do you talk from a specific file?
    – xoned
    Commented Mar 23, 2013 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
    Commented Mar 23, 2013 at 14:31

4 Answers 4


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"

  • I tried that, but it asks always for the password. I also tried to add a NOPASSWD: behind the (ALL).
    – xoned
    Commented Mar 29, 2013 at 16:19
  • @Timo can you try again? See my updates
    – daisy
    Commented Mar 29, 2013 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.
    – xoned
    Commented Mar 30, 2013 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
    Commented Jun 14, 2014 at 14:00
  • 1
    Rather than issue permissions to ALL, it would be better from a security point of view, to give the permission to a User Group, and then make the relevant User(s) a member of that Group.
    – MikeW
    Commented Jul 4, 2019 at 10:19

additional way to archive permission changes is with an udev rule:

$ cat /etc/udev/rules.d/99-asus.rules

# allow keyboard brightness control for everyone
ACTION=="add", SUBSYSTEM=="leds", KERNEL=="asus::kbd_backlight", RUN+="/bin/chmod a+w /sys/class/leds/%k/brightness"

to test the rule try with
udevadm test /sys/class/leds/asus::kbd_backlight
in the report you should see the specified Run command.

and to trigger it use
sudo udevadm trigger --verbose --action=add /sys/class/leds/asus::kbd_backlight

based on this answer


I had a similar problem, I needed to set the permissions before running the nodered service. Following the comment of goldilocks I created this systemd script:

$ cat /etc/systemd/system/setledspermissions.service

Description=Set leds writable to everybody

ExecStart=/bin/bash -c "/bin/chmod a+w /sys/class/leds/led0/*"


After writing the service file I enabled it with

$ sudo systemctl enable setledspermissions.service
$ sudo systemctl start setledspermissions.service
$ sudo systemctl status setledspermissions.service
  • Is this generally the way to go when needing to grant write access to specific /sys/ paths? My use case is setting the screen backlight brightness on my ĺaptop.
    – Richrd
    Commented Aug 9, 2018 at 19:44
  • I guess it is because the sys path is recreated each boot. But i'm not expert enough to be sure about that. Commented Aug 11, 2018 at 0:09

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).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .