0

I have just install brightnessctl to control my screen brightness, but can only run it as root. Doing otherwise prints the suggestion I "get write permission for device files". What is the correct way to do this? I would also like to be able to set volume with amixer without root privileges, which I assume is the same issue.

3 Answers 3

0

Many device access problems can be resolved through group membership changes.

You can find the device name by watching sudo journalctl --follow as you connect your device. OR ls -1 /dev >dev.before, connect the device, wait 10 seconds, ls -1 /dev >dev.after;diff dev.{before,after}.

Specifically, if ls -l shows that the group permissions (the second "rwx" triplet) is "rw" (e.g."-rw-rw----"), then, adding oneself to the group that owns the device will grant rw access.

Here's how:

# change to your device name 
device="/dev/dvdrw"
sudo adduser $USER $(stat -c "%G" $device)

This allows you membership in the group that can rw the device, but there is one more step.

To make all your processes members of the new group, logout and login. Group memberships are set up at login time.

To create a single process in the new group (for testing, prior to logout/login):

newgrp $(stat -c "%G" $device)  

or, just type the group name. See man newgrp.

0

Options:

  1. Recommended: Configure sudo so you can execute it as a normal user.

  2. Write a script with suid root to execute brightnessctl. (Don't try to suid root directly on brightnessctl, because assuming you used a package manager, this won't survive the next upgrade) Depending on how you write the script, this may open up a security hole.

  3. Identify the device files in question, write udev rules to set permission after creation. Not fun to write or debug.


I would also like to be able to set volume with amixer without root privileges

I can use amixer without root privileges just fine, so for this, I'd either suspect some weird setup on your distro/your machine. Or, if your distro is like mine, you have not made your use a member of the group that has permissions to do audio things (audio on my distro, just edit /etc/group, or use whatever tools your distro has for that).

0

You have to add yourself to the video and the input groups, then brightnessctl should just work fine. See https://github.com/Hummer12007/brightnessctl/issues/63.

You must log in to answer this question.

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