How to use the command 'lsusb' (with examples)
- Linux
- December 25, 2023
The ’lsusb’ command is used to display information about the USB buses and devices connected to them on a Linux system. It provides a way to list the available USB devices, hierarchical information, verbose details, and specific information about a particular device.
Use case 1: List all the USB devices available
Code:
lsusb
Motivation: This use case is useful when you want to quickly identify all the USB devices connected to your system. The ’lsusb’ command provides a concise list of all the USB devices, including the vendor and product IDs.
Explanation:
lsusb
: This is the command itself, which is used to list the USB devices.
Example output:
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 003: ID 8087:0a2b Intel Corp.
Bus 001 Device 002: ID 0bda:0129 Realtek Semiconductor Corp. RTS5129 Card Reader Controller
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
...
Use case 2: List the USB hierarchy as a tree
Code:
lsusb -t
Motivation: This use case is helpful when you want to visualize the USB hierarchy to understand how the USB devices are connected to the system.
Explanation:
lsusb
: The command itself.-t
: This option is used to display the USB hierarchy as a tree.
Example output:
/: Bus 02.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/8p, 480M
|__ Port 4: Dev 3, If 0, Class=Vendor Specific Class, Driver=r8152, 480M
|__ Port 7: Dev 2, If 0, Class=Vendor Specific Class, Driver=btusb, 12M
/: Bus 01.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/12p, 5000M
|__ Port 3: Dev 3, If 0, Class=Wireless, Driver=btusb, 12M
|__ Port 6: Dev 2, If 2, Class=Mass Storage, Driver=usb-storage, 5000M
Use case 3: List verbose information about USB devices
Code:
lsusb --verbose
Motivation: This use case is useful when you need detailed information about the USB devices connected to your system, including device descriptors, configurations, interfaces, and more.
Explanation:
lsusb
: The command itself.--verbose
: This option is used to display verbose information about the USB devices.
Example output:
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Device Descriptor:
bLength 18
...
Interface Descriptor:
...
Use case 4: List detailed information about a USB device
Code:
lsusb --verbose -s bus:device number
Motivation: This use case is helpful when you want to view detailed information about a specific USB device by specifying its bus and device number.
Explanation:
lsusb
: The command itself.--verbose
: This option is used to display detailed information.-s bus:device
: This option is used to specify the bus and device number of the USB device.
Example output:
Bus 001 Device 003: ID 8087:0a2b Intel Corp.
Device Descriptor:
bLength 18
...
Interface Descriptor:
...
Use case 5: List devices with a specified vendor and product ID only
Code:
lsusb -d vendor:product
Motivation: This use case is useful when you want to filter the USB devices based on a specific vendor and product ID, allowing you to narrow down the list to the desired devices.
Explanation:
lsusb
: The command itself.-d vendor:product
: This option is used to filter the devices based on the specified vendor and product ID.
Example output:
Bus 001 Device 002: ID 0bda:0129 Realtek Semiconductor Corp. RTS5129 Card Reader Controller
Conclusion:
The ’lsusb’ command provides a convenient way to get information about USB buses and devices connected to them on a Linux system. By using different options, you can list all available devices, view the USB hierarchy, get detailed and verbose information, and filter devices based on specific vendor and product IDs. This command is helpful for troubleshooting USB-related issues, identifying connected devices, and understanding the USB topology.