I'm waiting for my Pi. From reading the tutorials and books on doing i/o on the Pi I'm getting the impression that linux makes entries in /dev on the fly, which is nice, but they're owned by someone other than the pi user. Is there a way to have Linux make the /dev entries world writable or owned by pi?
You can change the permissions on a device node using
chmod g+rw /dev/whatever
This adds read/write permissions for the group owning 'whatever'. A lot of stuff in /dev is uid and gid 0 (owner root, group root) but some things have a separate group such as 'video' or 'disk', and when this is the case, the group will already have read write permissions on the node. So, first check if the node you are interested in is like that:
stat -c "%A %G" /dev/whatever
If so, just add the pi user to that group. If the group is called "mydevice":
usermod -a -G mydevice pi
Done. If the node does not belong to a special group, you can create one:
Note on some distros this command is
groupadd. Now chown the device to that group and tweak the permissions:
chown root.mydevice /dev/whatever chmod g+rw /dev/whatever
Then add the pi user to the group. The new group, and the pi user's membership in it, are permanent (until you change them again). However, the dev nodes are actually created at boot, so any changes you make to them will not persist. You can make that permanent by adding a udev rule. Create a text file in
/etc/udev/rules.d called mydevice.rules (or anything with the suffix
.rules) and add a rule:
KERNEL=="whatever", NAME="%k", GROUP="mydevice", MODE="0660"
Beware the difference between == and = there. Here's a (slightly aged) guide to udev rules, most of which still seems to be valid.