0

Okay...so I have used chown and chmod as directed by many tutorials to access some /dev/ files for peripherals.

The chown and chmod does not make it past a reboot. This is okay. The issue I am seeing has to do with not being able to manipulate the /dev/ directory files, for instance gpio and/or i2c, with success even after using chmod and/or chown...

So, I set my naming scheme for the current user and then set my group for that user but still without access to my files. I am using a embedded computer with a Specification that dictates files be filled in /dev/bone/ for some peripheral files like pwm, uart, and i2c.

Is /dev/ special in that controlling files from within /dev/ cannot be affected by commanding permissions and user:group additions w/ chown and chmod?

Still trying to wrap my education around the build in /dev/ while not using /sys/class/gpio/ and/or /sys/class/pwm/.

1

1 Answer 1

0

The /dev/ directory tree is generated anew when the system boots. After all, you may have added/removed hardware.

Many device access problems are permission problems, and 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 -l /dev >dev.before, connect the device, wait 10 seconds, ls -1 -l /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/YourDevice"
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.

4
  • Thank you. I will sign in soon and return service.
    – For Ward
    Jan 7 at 22:13
  • Okay, so I am using WSL2 on Windows 11 but the target is a Linux based controller. I usually ssh and sftp to/from the board from WSL2. I am not sure what steps are taken to go that far just yet. I will have to reconvene on a Bookworm Distro soon. Until then, sorry it is takin me so long: @waltinator
    – For Ward
    Jan 8 at 0:12
  • Unix&Linux is a Q&A site, not a conversation site. If you have new information on your original question, edit the question and add it. If you have a new question, How to Ask it. Do not try to start conversations in a Comment.
    – waltinator
    Jan 8 at 0:27
  • Okay. You got it.
    – For Ward
    Jan 8 at 3:38

You must log in to answer this question.

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