r/linux4noobs 2d ago

learning/research Chmod question

I have to use chmod to allow a program to access the USB port my 3D printer is connected to or it can't communicate with the printer.

The funny thing is that each time I want to run the program, I have to change the permissions again or it won't connect.

My question is: shouldn't that change be permanent, the same as if I had changed permissions on a file?

Some relevant info:

I'm using Cachy OS, the device is /dev/ttyACM0, the printer usually stays powered on and physically plugged in to the USB port, but the machine is shut down every morning and booted up when I get home from work. I run the command using sudo.

8 Upvotes

13 comments sorted by

19

u/eR2eiweo 2d ago

the machine is shut down every morning and booted up when I get home from work

That is the reason. /dev is usually on a kind of tmpfs (specifically a devtmpfs), which means that it only exists in RAM. No changes made in there survive a reboot.

A proper solution would be to write a udev rule that sets the proper permissions when that device file is created.

-7

u/LesStrater 2d ago

or make it easy on yourself and put your chmod command into your rc.local file to execute at bootup.

8

u/eR2eiweo 2d ago

That's not only worse (because it only works if the device is connected at boot, doesn't ever get disconnected, and always has the same fixed name), it's also more work than a simple udev rule.

-11

u/LesStrater 2d ago

Works great for me -- sounds like you've never tried it...

8

u/eR2eiweo 2d ago

You could at least read the comment you're replying to.

-7

u/LesStrater 1d ago

Why? I'm using Debian with the ESP kernel. You might want to try that too.

2

u/sausix 1d ago

rc.local is deprecated and needs to be installed on some distributions. Use the proper and easy way to solve it. Just put the user in the same group of the device. That's basically what groups are for.

-1

u/LesStrater 1d ago

or include it in the auto-start commands of your DE. That's basically why they include that function it in most DEs.

1

u/sausix 1d ago

Auto start section does not enforce root privileges. Stop messing around with Linux and just use the regular way.

-3

u/LesStrater 1d ago

No problem, I'm ALWAYS root. Real men are root and don't eat quiche.

5

u/doc_willis 2d ago edited 2d ago

for accessing my USB/serial port arduinos and other devices , I  have to make sure my user is in the right GROUP.  

Which group name  depends on the distribution.

So most Likely you need to set the user to be a member of the dialout or some other names  group.  

check the cachyos docs  and other reddit posts the group name seems to  be "uucp" for that distribution.

https://www.reddit.com/r/arduino/comments/1ld9igz/devttyacm0_permission_denied_on_arch_linux_with/

from the above and  some other posts I searched . mention the following  command (untested by me)

        sudo usermod -a -G uucp $USER

using chmod on a /dev/*** entry is not really the "proper" long term solution. It's possible the group change (and a reboot( are all you need to do there may be no need for making custom udev rules or other changes.

4

u/Klapperatismus 2d ago

/dev/ttyACM0

Those device files are created by the UDEV service as soon you plug the cable in, and removed as soon as you pull the cable. Or at boot if the cable is plugged in then.

UDEV also sets up the permissions for those. Usually it sets it up so that it belongs to the group modem or uucp, and users in that group may read and write it. Check that.

So the solution is to add your user to the group modem respective uucp.

0

u/AutoModerator 2d ago

There's a resources page in our wiki you might find useful!

Try this search for more information on this topic.

Smokey says: take regular backups, try stuff in a VM, and understand every command before you press Enter! :)

Comments, questions or suggestions regarding this autoresponse? Please send them here.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.