2

I'm trying to set group attribute for

root@luna:~# ls -l /sys/class/backlight/intel_backlight/brightness -rw-r--r-- 1 root root 4096 Sep 24 08:28 /sys/class/backlight/intel_backlight/brightness 

I've created a rule in /etc/udev/rules.d/99-local.rules:

root@luna:/etc/udev/rules.d# cat 99-local.rules KERNEL=="intel_backlight", SUBSYSTEM=="backlight", GROUP="neil", mode="0664" 

Whether I systemctl restart udev, udevadm control -R, or reboot the rule is not applied. What have I done wrong?

2 Answers 2

5

Udev creates device file entries under /dev. Udev rules affect those entries. Files under /sys are direct kernel interfaces, created by the kernel, and not affected by udev.

If you want to change ownership or permissions on a file under /sys, do it explicitly.

#!/bin/sh chown neil /sys/class/backlight/intel_backlight/brightness chmod 664 /sys/class/backlight/intel_backlight/brightness 

If the display device fires a udev event then you can run this script with a RUN=… action. Alternatively, run this script somewhere in the boot process, e.g. in /etc/rc.local.

3

I just came across this question. The proper way to change the permission & ownership of files under /sys is by using tmpfiles configs. For example, placing the following in /etc/tmpfiles.d/screen-backlight.conf would achieve what you want:

m /sys/class/backlight/intel_backlight/brightness 0664 root some_group_that_neil_belongs_to - - 

See man 5 tmpfiles.d for all the options.

2
  • There's no such modifier as "m", I think you meant "z" (or "Z" for recursive). Commented Feb 19, 2020 at 12:13
  • I never used tmpfiles but I'm upvoting since the man page explicitly says that it is used to /sys: "...It is mostly commonly used for volatile and temporary files and directories (such as those located under /run/, /tmp/, /var/tmp/, the API file systems such as /sys/ or /proc/, as well as some other directories below /var/)." Commented Jan 21, 2021 at 15:42

You must log in to answer this question.