Accessing USB devices as non-root: writing udev rules the easy way

I recently purchased a TEMPered USB thermometer, which I wanted to use as non-root using an open source utility called TEMPered. All the recipes I found, required that I use root to access the /dev/hidraw0 device that the particular TEMPered USB device exposed – of course this was not acceptable.

systemd (and udev, in general – I believe) has a handy utility called udevadm. You can use this tool to query a device on your system, for example:

udevadm info --query=all --name=/dev/hidraw0 --attribute-walk

Which allows you to retrieve all the required attributes to craft a file to put in /etc/dev/rules.d. I have created the following to expose PCsensor TEMPerV1.4 to a user that is part of the group temper:

# TEMPer1.4 USB thermometer
SUBSYSTEM=="hidraw", ATTRS{idVendor}=="0c45", ATTRS{idProduct}=="7401", GROUP="temper", MODE="0660"

I placed this in a file called /etc/udev/rules.d/60-temper.rules. You can now use TEMPered as a non-root user, which is a member of the group in question!