On Linux, the lsusb command lists all USB devices connected to a host (a computer). In this post, I will describe the information contained in its output. To start, open a terminal and run:
lsusb -t
This is the output I get on my laptop:
/: Bus 02.Port 1: Dev 1, Class=root_hub, Driver=ehci_hcd/3p, 480M |__ Port 1: Dev 2, If 0, Class=hub, Driver=hub/8p, 480M |__ Port 6: Dev 4, If 0, Class=hub, Driver=hub/3p, 12M |__ Port 1: Dev 5, If 0, Class=HID, Driver=usbhid, 12M |__ Port 2: Dev 6, If 0, Class=HID, Driver=, 12M |__ Port 3: Dev 7, If 0, Class='bInterfaceClass 0xe0 not yet handled', Driver=btusb, 12M |__ Port 3: Dev 7, If 1, Class='bInterfaceClass 0xe0 not yet handled', Driver=btusb, 12M |__ Port 3: Dev 7, If 2, Class=vend., Driver=, 12M |__ Port 3: Dev 7, If 3, Class=app., Driver=, 12M /: Bus 01.Port 1: Dev 1, Class=root_hub, Driver=ehci_hcd/3p, 480M |__ Port 1: Dev 2, If 0, Class=hub, Driver=hub/6p, 480M |__ Port 4: Dev 3, If 0, Class='bInterfaceClass 0x0e not yet handled', Driver=uvcvideo, 480M |__ Port 4: Dev 3, If 1, Class='bInterfaceClass 0x0e not yet handled', Driver=uvcvideo, 480M
The output shows a list of USB host controllers (the lines starting with "Bus") and their connected devices on a tree structure. This tree describes the actual physical hierarchy of the USB devices (who is connected to whom). At the end of each line, the negotiated communication speed for each device is shown in Mbits/s. The 12Mbit/s mode is called "Full Speed" and is used for communicating with keyboards, mice, joysticks and similar devices. The 480Mbit/s is called "Hi-Speed" and is used for communicating with storage devices, webcams and other devices for which more bandwidth is required. All my ports are USB 2.0; for USB 3.0 there is a communication mode which supports 5000Mbit/s (5Gbit/s).
As the output shows, my laptop has two USB host controllers. Both controllers are managed by an ECHI driver ("Driver=ehci_hcd/3p"). Indeed, USB 2.0 ports must be managed by either an EHCI or an xHCI driver. Each host controller contains a hub directly attached to it called a root hub (notice the string "Class=root_hub" on their lines).
The device numbers are simply indices which are attributed to USB devices as they are detected: if you remove a device and reinsert it, it will come up again with a different device number.
Now let's focus on bus #2. There is a USB hub connected to its port #1 (device 2). A second USB hub is attached to port #6 of the first USB hub (device 4). This second hub is attached to several devices. Although both USB hubs are internal (they are physically inside my laptop), the first hub is connected to the external USB ports (the ones I can directly access) while all ports of the second hub are internal. Indeed, if I connect a USB disk to one of my USB ports, the output of lsusb -t becomes:
/: Bus 02.Port 1: Dev 1, Class=root_hub, Driver=ehci_hcd/3p, 480M
|__ Port 1: Dev 2, If 0, Class=hub, Driver=hub/8p, 480M
|__ Port 2: Dev 8, If 0, Class=stor., Driver=usb-storage, 480M
|__ Port 6: Dev 4, If 0, Class=hub, Driver=hub/3p, 12M
|__ Port 1: Dev 5, If 0, Class=HID, Driver=usbhid, 12M
|__ Port 2: Dev 6, If 0, Class=HID, Driver=, 12M
|__ Port 3: Dev 7, If 0, Class='bInterfaceClass 0xe0 not yet handled', Driver=btusb, 12M
|__ Port 3: Dev 7, If 1, Class='bInterfaceClass 0xe0 not yet handled', Driver=btusb, 12M
|__ Port 3: Dev 7, If 2, Class=vend., Driver=, 12M
|__ Port 3: Dev 7, If 3, Class=app., Driver=, 12M
/: Bus 01.Port 1: Dev 1, Class=root_hub, Driver=ehci_hcd/3p, 480M
|__ Port 1: Dev 2, If 0, Class=hub, Driver=hub/6p, 480M
|__ Port 4: Dev 3, If 0, Class='bInterfaceClass 0x0e not yet handled', Driver=uvcvideo, 480M
|__ Port 4: Dev 3, If 1, Class='bInterfaceClass 0x0e not yet handled', Driver=uvcvideo, 480M
The highlighted line shows a new USB device (a storage device) directly connected to the first USB hub of bus #2 (I have tried every single USB port on my laptop: the USB disk is always detected on a port from that hub). To find out more about the devices on the second hub, I ran:
lsusb
and got this output:
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 8087:0020 Intel Corp. Integrated Rate Matching Hub
Bus 002 Device 002: ID 8087:0020 Intel Corp. Integrated Rate Matching Hub
Bus 001 Device 003: ID 0c45:6460 Microdia
Bus 002 Device 004: ID 0a5c:4500 Broadcom Corp. BCM2046B1 USB 2.0 Hub (part of BCM2046 Bluetooth)
Bus 002 Device 005: ID 413c:8161 Dell Computer Corp. Integrated Keyboard
Bus 002 Device 006: ID 413c:8162 Dell Computer Corp. Integrated Touchpad [Synaptics]
Bus 002 Device 007: ID 413c:8160 Dell Computer Corp. Wireless 365 Bluetooth
The highlighted devices are the ones which are connected to the second hub of bus #2. They are given the device numbers 5, 6 and 7. Device 5 is my laptop's keyboard and device 6 is my touchpad. This makes sense since the class of these devices (shown on the output of lsusb -t) is HID (Human Interface Device). Device 7 is my Bluetooth card. As I initially suspected, all ports from the second hub are indeed internal.
Strings such as "ID 413c:8161" say that the vendor ID is 413c (Dell Computer Corp.) and the product ID is 8161 (Integrated Keyboard). To clarify, each USB device contains a vendor ID and a product ID (companies pay to acquire vendor IDs from the USB Implementers Forum). A list of vendor IDs with their respective product IDs can be found here.
If the output from lsusb is too long, you can restrict it to a specific USB device by running:
lsusb -s <bus>:<device-number>
For example, with bus=2 and device=5:
lsusb -s 2:5
I get the following:
Bus 002 Device 005: ID 413c:8161 Dell Computer Corp. Integrated Keyboard
Bonus: usb-devices
If lsusb does not give you the information you want for a given device, try running:
usb-devices
This will show you a comprehensive and very detailed list of your USB devices. With the bus and device numbers, you can go through the list and see if it provides more information about the device you are interested in.
Comments
Kudos for concise, yet comprehensive explanation!