$ lsusb Bus 006 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub Bus 005 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 002: ID 8087:0a2b Intel Corp. Bluetooth wireless interface Bus 001 Device 029: ID 03f0:1a47 HP, Inc USB2.1 Hub Bus 001 Device 028: ID 03f0:1a47 HP, Inc USB2.1 Hub Bus 001 Device 006: ID 03f0:1a47 HP, Inc USB2.1 Hub Bus 001 Device 004: ID 03f0:1a47 HP, Inc USB2.1 Hub Bus 001 Device 003: ID 045e:00db Microsoft Corp. Natural Ergonomic Keyboard 4000 V1.0 Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub Bus 003 Device 002: ID 0424:3fb7 Microchip Technology, Inc. (formerly SMSC) Babyface (23509439) Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Device are mainly identified using a pair of hexadecimal numbers, like 04b3:3108.
The 4 first hexadecimal digits are the Vendor ID (04b3 = IBM). The 4 last hexadecimal digits are the Device ID (3108 = ThinkPad 800dpi Optical Travel Mouse).
$ sudo cat /sys/kernel/debug/usb/devices | grep -E "^([TSPD]:.*|)$" T: Bus=01 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#= 1 Spd=480 MxCh=16 D: Ver= 2.00 Cls=09(hub ) Sub=00 Prot=01 MxPS=64 #Cfgs= 1 P: Vendor=1d6b ProdID=0002 Rev= 5.10 S: Manufacturer=Linux 5.10.0-3-amd64 xhci-hcd S: Product=xHCI Host Controller S: SerialNumber=0000:00:14.0 ....
For determining SUBSYSTEM=="usb" and DRIVER=="usb" matches in udev rules:
$ udevadm monitor - u monitor will print the received events for: UDEV - the event which udev sends out after rule processing KERNEL - the kernel uevent KERNEL[1204590.728813] add /devices/pci0000:00/0000:00:14.0/usb1/1-1 (usb) KERNEL[1204590.731320] add /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0 (usb) KERNEL[1204590.731375] bind /devices/pci0000:00/0000:00:14.0/usb1/1-1 (usb) UDEV [1204590.740420] add /devices/pci0000:00/0000:00:14.0/usb1/1-1 (usb) KERNEL[1204590.759474] add /class/scsi_host (class) KERNEL[1204590.759495] add /bus/scsi (bus) ....
$ udevadm info -a --path=/sys//devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0/host0/target0:0:0/0:0:0:0/block/sda/sda1 Udevadm info starts with the device specified by the devpath and then walks up the chain of parent devices. It prints for every device found, all possible attributes in the udev rules key format. A rule to match, can be composed by the attributes of the device and the attributes from one single parent device. looking at device '/devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0/host0/target0:0:0/0:0:0:0/block/sda/sda1': KERNEL=="sda1" SUBSYSTEM=="block" DRIVER=="" ATTR{alignment_offset}=="0" ATTR{discard_alignment}=="0" ATTR{inflight}==" 0 0" ATTR{partition}=="1" ATTR{power/async}=="disabled" ATTR{power/control}=="auto" ATTR{power/runtime_active_kids}=="0" ATTR{power/runtime_active_time}=="0" ATTR{power/runtime_enabled}=="disabled" ATTR{power/runtime_status}=="unsupported" .....
$ udevadm info /dev/sda P: /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0/host0/target0:0:0/0:0:0:0/block/sda N: sda L: 0 S: disk/by-uuid/2019-07-06-10-36-43-00 S: disk/by-label/d-live\x2010.0.0\x20st\x20amd64 S: disk/by-path/pci-0000:00:14.0-usb-0:1:1.0-scsi-0:0:0:0 S: disk/by-id/usb-Kingston_DataTraveler_2.0_001A928EED051071C97002E2-0:0 E: DEVPATH=/devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0/host0/target0:0:0/0:0:0:0/block/sda E: DEVNAME=/dev/sda E: DEVTYPE=disk E: MAJOR=8 E: MINOR=0 E: SUBSYSTEM=block E: USEC_INITIALIZED=1204591933431 E: ID_VENDOR=Kingston E: ID_VENDOR_ENC=Kingston E: ID_VENDOR_ID=0951 E: ID_MODEL=DataTraveler_2.0 E: ID_MODEL_ENC=DataTraveler\x202.0 E: ID_MODEL_ID=1665 .....
- /lib/udev/rules.d/ β The default rules directory
- /etc/udev/rules.d/ β The custom rules directory. These rules take precedence.