« Back to Frequently Asked Questions

How to list all USB devices

Most modern hardware has USB support. Therefore most Linux kernels have modular support for USB devices as well, making it easy to plug a device and get started with it. Sometimes you may need to retrieve the details and then it is useful to know how to query the available USB devices and the details.

Show list of connected USB devices

To show available USB devices, the lsusb command is a good start.

lsusb

Retrieving more details

Combine the number of lines and specify a unit to see more relevant entries.

# lsusb --tree
/:  Bus 06.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/4p, 10000M
/:  Bus 05.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/2p, 480M
/:  Bus 04.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/4p, 10000M
    |__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/4p, 10000M
        |__ Port 3: Dev 4, If 0, Class=Video, Driver=uvcvideo, 5000M
        |__ Port 3: Dev 4, If 1, Class=Video, Driver=uvcvideo, 5000M
        |__ Port 3: Dev 4, If 2, Class=Audio, Driver=snd-usb-audio, 5000M
        |__ Port 3: Dev 4, If 3, Class=Audio, Driver=snd-usb-audio, 5000M
        |__ Port 3: Dev 4, If 4, Class=Human Interface Device, Driver=usbhid, 5000M
    |__ Port 4: Dev 3, If 0, Class=Hub, Driver=hub/2p, 10000M
/:  Bus 03.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/12p, 480M
    |__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/4p, 480M
        |__ Port 4: Dev 9, If 0, Class=Human Interface Device, Driver=usbhid, 12M
        |__ Port 2: Dev 8, If 1, Class=Human Interface Device, Driver=usbhid, 12M
        |__ Port 2: Dev 8, If 0, Class=Human Interface Device, Driver=usbhid, 12M
        |__ Port 1: Dev 5, If 0, Class=Human Interface Device, Driver=usbhid, 480M
    |__ Port 2: Dev 3, If 0, Class=Hub, Driver=hub/2p, 480M
        |__ Port 2: Dev 6, If 0, Class=Human Interface Device, Driver=usbhid, 12M
    |__ Port 4: Dev 4, If 0, Class=Human Interface Device, Driver=usbhid, 12M
    |__ Port 4: Dev 4, If 1, Class=Human Interface Device, Driver=usbhid, 12M
    |__ Port 4: Dev 4, If 2, Class=Human Interface Device, Driver=usbhid, 12M
    |__ Port 4: Dev 4, If 3, Class=Human Interface Device, Driver=usbhid, 12M
    |__ Port 4: Dev 4, If 4, Class=Human Interface Device, Driver=usbhid, 12M
    |__ Port 10: Dev 7, If 0, Class=Wireless, Driver=btusb, 12M
    |__ Port 10: Dev 7, If 1, Class=Wireless, Driver=btusb, 12M
/:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/4p, 10000M
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/1p, 480M

To get more details, add the --verbose option.

/sys/bus/usb/devices

Another option is to look in the directories located under /sys/bus/usb/devices. A numbered set of directories lists each devices and all its available parameters.

# ls -l /sys/bus/usb/devices/usb1/
total 0
drwxr-xr-x 6 root root     0 Apr 17 19:08 1-0:1.0
drwxr-xr-x 5 root root     0 Apr 17 19:08 1-1
-rw-r--r-- 1 root root  4096 Apr 28 22:55 authorized
-rw-r--r-- 1 root root  4096 Apr 28 22:55 authorized_default
-rw-r--r-- 1 root root  4096 Apr 28 22:55 avoid_reset_quirk
-rw-r--r-- 1 root root  4096 Apr 17 19:08 bConfigurationValue
-r--r--r-- 1 root root  4096 Apr 17 19:08 bDeviceClass
-r--r--r-- 1 root root  4096 Apr 28 22:55 bDeviceProtocol
-r--r--r-- 1 root root  4096 Apr 28 22:55 bDeviceSubClass
-r--r--r-- 1 root root  4096 Apr 28 22:55 bMaxPacketSize0
-r--r--r-- 1 root root  4096 Apr 28 22:55 bMaxPower
-r--r--r-- 1 root root  4096 Apr 28 22:55 bNumConfigurations
-r--r--r-- 1 root root  4096 Apr 28 22:55 bNumInterfaces
-r--r--r-- 1 root root  4096 Apr 17 19:08 bcdDevice
-r--r--r-- 1 root root  4096 Apr 28 22:55 bmAttributes
-r--r--r-- 1 root root  4096 Apr 17 19:08 busnum
-r--r--r-- 1 root root  4096 Apr 28 22:55 configuration
-r--r--r-- 1 root root 65553 Apr 17 19:08 descriptors
-r--r--r-- 1 root root  4096 Apr 28 22:55 dev
-r--r--r-- 1 root root  4096 Apr 17 19:08 devnum
-r--r--r-- 1 root root  4096 Apr 28 22:55 devpath
lrwxrwxrwx 1 root root     0 Apr 17 19:08 driver -> ../../../../bus/usb/drivers/usb
drwxr-xr-x 3 root root     0 Apr 17 19:08 ep_00
-r--r--r-- 1 root root  4096 Apr 17 19:08 idProduct
-r--r--r-- 1 root root  4096 Apr 17 19:08 idVendor
-rw-r--r-- 1 root root  4096 Apr 28 22:55 interface_authorized_default
-r--r--r-- 1 root root  4096 Apr 28 22:55 ltm_capable
-r--r--r-- 1 root root  4096 Apr 17 19:08 manufacturer
-r--r--r-- 1 root root  4096 Apr 28 22:55 maxchild
drwxr-xr-x 2 root root     0 Apr 17 19:08 power
-r--r--r-- 1 root root  4096 Apr 17 19:08 product
-r--r--r-- 1 root root  4096 Apr 28 22:55 quirks
-r--r--r-- 1 root root  4096 Apr 28 22:55 removable
--w------- 1 root root  4096 Apr 28 22:55 remove
-r--r--r-- 1 root root  4096 Apr 28 22:55 rx_lanes
-r--r--r-- 1 root root  4096 Apr 17 19:08 serial
-r--r--r-- 1 root root  4096 Apr 17 19:08 speed
lrwxrwxrwx 1 root root     0 Apr 26 12:36 subsystem -> ../../../../bus/usb
-r--r--r-- 1 root root  4096 Apr 28 22:55 tx_lanes
-rw-r--r-- 1 root root  4096 Apr 26 12:36 uevent
-r--r--r-- 1 root root  4096 Apr 28 22:55 urbnum
-r--r--r-- 1 root root  4096 Apr 28 22:55 version

Monitor using udevadm

For troubleshooting or discovering a specific device, there might be a better way. With the help of udevadm we can tell it to monitor for events related to the USB subsystem. This makes it easy to learn more about a particular device by plugging it in, or removing it again.

# udevadm monitor --subsystem-match=usb --udev
monitor will print the received events for:
UDEV - the event which udev sends out after rule processing

UDEV  [1203685.522963] add      /devices/pci0000:00/0000:00:14.0/usb3/3-2/3-2.1 (usb)
UDEV  [1203685.526742] add      /devices/pci0000:00/0000:00:14.0/usb3/3-2/3-2.1/3-2.1:1.0 (usb)
UDEV  [1203685.529552] add      /devices/pci0000:00/0000:00:14.0/usb3/3-2/3-2.1/3-2.1:1.1 (usb)
UDEV  [1203685.547246] bind     /devices/pci0000:00/0000:00:14.0/usb3/3-2/3-2.1/3-2.1:1.1 (usb)
UDEV  [1203685.602013] bind     /devices/pci0000:00/0000:00:14.0/usb3/3-2/3-2.1/3-2.1:1.0 (usb)
UDEV  [1203685.606676] bind     /devices/pci0000:00/0000:00:14.0/usb3/3-2/3-2.1 (usb)
UDEV  [1203699.839437] unbind   /devices/pci0000:00/0000:00:14.0/usb3/3-2/3-2.1/3-2.1:1.0 (usb)
UDEV  [1203699.840795] remove   /devices/pci0000:00/0000:00:14.0/usb3/3-2/3-2.1/3-2.1:1.0 (usb)
UDEV  [1203699.885635] unbind   /devices/pci0000:00/0000:00:14.0/usb3/3-2/3-2.1/3-2.1:1.1 (usb)
UDEV  [1203699.886440] remove   /devices/pci0000:00/0000:00:14.0/usb3/3-2/3-2.1/3-2.1:1.1 (usb)
UDEV  [1203699.887547] unbind   /devices/pci0000:00/0000:00:14.0/usb3/3-2/3-2.1 (usb)
UDEV  [1203699.888441] remove   /devices/pci0000:00/0000:00:14.0/usb3/3-2/3-2.1 (usb)

In this example we see add and bind events when the device is plugged in. After removal, the unbind and remove events show up.

Relevant commands in this article

Like to learn more about the commands that were used in this article? Have a look, for some there is also cheat sheet available.

  • lsusb
  • udevadm

Feedback

Small picture of Michael Boelen

This article has been written by our Linux security expert Michael Boelen. With focus on creating high-quality articles and relevant examples, he wants to improve the field of Linux security. No more web full of copy-pasted blog posts.

Discovered outdated information or have a question? Share your thoughts. Thanks for your contribution.

Mastodon icon