I have a USB scale, a USB HID. Currently, when it is plugged in, the permissions only allow the superuser to access it. How can I configure udev to let anybody access this device? I have the vendor and product IDs, but I would like to match it based on the HID type instead.
Right now, I'm having trouble finding any existing rule that applies to this (I grepped for "hidraw" in /lib/udev/rules.d
and /etc/udev/rules.d
, among other things).
Normally, this is done by adding to
/etc/udev/rules.d
a file maybe named50-usb-scale.conf
with contents like this:Where HEX1 and HEX2 are replaced with the vendor and product id respectively.
To match on the Interface type instead, you could try replacing
ATTR{idVendor}=="HEX1", ATTR{idProduct}=="HEX2"
with a match forbInterfaceClass
being03
(HID):But be warned, that will catch mice and keyboards too.
Just for the summary:
You may filter for:
And use:
== Compare for equality.
!= Compare for inequality.
= Assign a value to a key. Keys that represent a list are reset and only this single value is assigned.
+= Add the value to a key that holds a list of entries.
:= Assign a value to a key finally; disallow any later changes.
You may give a specific device a specific new path in /dev/...
Example:
Results in:
You can access the device via '/dev/hiddevx' or via '/dev/myhid' easyly, every user in group 'cdrom' may read from the device. Owner 'user28' may read and write.
or simplest:
Results in: Every user may access every hiddevice from Vendor 0x16c0
For details see: Docs
In case you need to change (like me)
ttyACM0
permissions, this are my settings:It failed when I tried to specify the vendor and product ID. I am not sure why.
If its a HIDRAW device, you have to
where X is the hid device number, e.g hidraw0. you can do
to see a list :) Or just do
to set for all hidraw devices, probably not recommended.
Ubuntu 18.04 update/clarification:
Kees Cook's answer is close but requires 2 changes to work in 18.04 (the current release and only one I've tested this on).
But with your idVendor and idProduct hex values.