Why does PyUSB / libusb require root (sudo) permissions on Linux?

ewall picture ewall · Sep 17, 2010 · Viewed 11k times · Source

I have been toying around with PyUSB lately, and found that it works beautifully on Linux (Ubuntu has libusb 0.1 and 1.0, as well as OpenUSB)... but only if I run the program with root privileges (with sudo, of course).

Can anyone tell me why it requires elevated privileges and, more importantly, if I can change the permissions somehow to make it work for normal user accounts?

Answer

Jaap Versteegh picture Jaap Versteegh · Dec 20, 2011

You can change the permissions of your usb device node by creating a udev rule. e.g. I added the following line to a file in /etc/udev/rules.d/

SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", MODE="0664", GROUP="usbusers"

This sets the owner of the device node to root:usbusers rather than root:root

After adding myself to the usbusers group, I can access the device.