1

I need to identify all USB ports on a Linux system without knowing in advance whether USB devices are plugged into them.

If a USB device is plugged into a port, by running lsusb -t I get the usb device hierarchy, where the port value is unique to the physical port the device is plugged into. For instance bus 3 port 3 for a mass storage device in this example:

$ lsusb -t
/:  Bus 04.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/6p, 5000M
/:  Bus 03.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/15p, 480M
    |__ Port 2: Dev 42, If 0, Class=Human Interface Device, Driver=usbhid, 1.5M
    |__ Port 3: Dev 41, If 0, Class=Mass Storage, Driver=usb-storage, 480M
    |__ Port 6: Dev 66, If 0, Class=Human Interface Device, Driver=usbhid, 1.5M
    |__ Port 6: Dev 66, If 1, Class=Human Interface Device, Driver=usbhid, 1.5M
    |__ Port 9: Dev 31, If 0, Class=Wireless, Driver=btusb, 12M
    |__ Port 9: Dev 31, If 1, Class=Wireless, Driver=btusb, 12M
    |__ Port 10: Dev 5, If 0, Class=Vendor Specific Class, Driver=qcserial, 480M
    |__ Port 10: Dev 5, If 2, Class=Vendor Specific Class, Driver=qcserial, 480M
    |__ Port 10: Dev 5, If 3, Class=Vendor Specific Class, Driver=qcserial, 480M
    |__ Port 10: Dev 5, If 8, Class=Vendor Specific Class, Driver=qmi_wwan, 480M
/:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=ehci-pci/2p, 480M
    |__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/8p, 480M
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=ehci-pci/2p, 480M
    |__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/6p, 480M
        |__ Port 5: Dev 3, If 0, Class=Video, Driver=uvcvideo, 480M
        |__ Port 5: Dev 3, If 1, Class=Video, Driver=uvcvideo, 480M

Any USB device attached to that physical port will be displayed as being on bus 3 port 3. The device number will increment as I plug in and out devices. If no device is plugged in on port 3, lsusb -t will not show that port.

Now, where do I get a list of all the real USB ports of a machine, regardless of whether USB devices are plugged?

5
  • 2
    You can’t. You can get a list of theoretically available ports, but you cannot know whether these ports are present physically.
    – Daniel B
    Jul 26, 2017 at 14:16
  • I see. So where do I get the list of all ports? Jul 26, 2017 at 14:27
  • 1
    It’s in the tree view already: hub/6p or hub/15p
    – Daniel B
    Jul 26, 2017 at 14:32
  • It's in the tree view iof lsusb -t if there is a device plugged into that port. Otherwise, the port won't be shown... Jul 26, 2017 at 14:34
  • 1
    Look again: The Driver= property contains the port count for hubs.
    – Daniel B
    Jul 26, 2017 at 14:41

0

You must log in to answer this question.

Browse other questions tagged .