Access USB device without sudo
The following instructions have only been tested on Arch Linux.
Create udev rule
List USB devices:
lsusb
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 003: ID 1532:024a Razer USA, Ltd Blade Stealth (Late 2019)
Bus 003 Device 002: ID 13d3:56d5 IMC Networks Integrated Camera
// 13d3 = idVendor, 56d5 = idProduct
Bus 003 Device 004: ID 8087:0026 Intel Corp. AX201 Bluetooth
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
cd /etc/udev/rules.d
sudo vim 10-my-usb.rules
Paste and edit the following content:
ATTRS{idVendor}=="13d3", ATTRS{idProduct}=="56d5", MODE="666", GROUP="evlos"
Then reload udev rules:
sudo udevadm trigger
Helpful Commands
sudo udevadm monitor
monitor will print the received events for:
UDEV - the event which udev sends out after rule processing
KERNEL - the kernel uevent
// Remove a device
KERNEL[53210.908336] remove /devices/pci0000:00/0000:00:14.0/usb4/4-2/4-2:1.0 (usb)
KERNEL[53210.908417] remove /devices/pci0000:00/0000:00:14.0/usb4/4-2/4-2:1.1 (usb)
KERNEL[53210.910366] unbind /devices/pci0000:00/0000:00:14.0/usb4/4-2 (usb)
KERNEL[53210.910434] remove /devices/pci0000:00/0000:00:14.0/usb4/4-2 (usb)
UDEV [53210.911622] remove /devices/pci0000:00/0000:00:14.0/usb4/4-2/4-2:1.0 (usb)
UDEV [53210.911917] remove /devices/pci0000:00/0000:00:14.0/usb4/4-2/4-2:1.1 (usb)
UDEV [53210.913751] unbind /devices/pci0000:00/0000:00:14.0/usb4/4-2 (usb)
UDEV [53210.924482] remove /devices/pci0000:00/0000:00:14.0/usb4/4-2 (usb)
// Insert a device
KERNEL[53217.243283] add /devices/pci0000:00/0000:00:14.0/usb4/4-2 (usb)
KERNEL[53217.246331] change /devices/pci0000:00/0000:00:14.0/usb4/4-2 (usb)
KERNEL[53217.247112] add /devices/pci0000:00/0000:00:14.0/usb4/4-2/4-2:1.0 (usb)
KERNEL[53217.247162] add /devices/pci0000:00/0000:00:14.0/usb4/4-2/4-2:1.1 (usb)
KERNEL[53217.247202] bind /devices/pci0000:00/0000:00:14.0/usb4/4-2 (usb)
UDEV [53217.822537] add /devices/pci0000:00/0000:00:14.0/usb4/4-2 (usb)
UDEV [53217.824902] change /devices/pci0000:00/0000:00:14.0/usb4/4-2 (usb)
UDEV [53217.826914] add /devices/pci0000:00/0000:00:14.0/usb4/4-2/4-2:1.0 (usb)
UDEV [53217.828439] add /devices/pci0000:00/0000:00:14.0/usb4/4-2/4-2:1.1 (usb)
UDEV [53217.834053] bind /devices/pci0000:00/0000:00:14.0/usb4/4-2 (usb)