How to Use the Command 'lsusb' (with Examples)

How to Use the Command 'lsusb' (with Examples)

The lsusb command is a valuable tool in the Linux environment that allows users to display information about USB buses and devices connected to them. It provides a wealth of information, ranging from a simple list of connected USB devices to detailed information about each device. It is often employed for troubleshooting and managing USB connections, as well as gathering data about the specifications and statuses of connected USB hardware. Understanding its various options can greatly enhance your ability to manage USB devices efficiently.

Use Case 1: Listing All USB Devices

Code:

lsusb

Motivation:

The simplest use of the lsusb command is to list all USB devices currently connected to your system. This can be especially useful when verifying that a device has been properly connected or when trying to troubleshoot connectivity issues. For instance, if you plug in a new USB device and it’s not functioning as expected, running lsusb can confirm whether your system recognizes the device.

Explanation:

  • lsusb: This is the command itself, with no additional arguments or options. By default, lsusb will display a list of all USB devices connected to the system.

Example Output:

Bus 002 Device 003: ID 05ac:027a Apple, Inc. Thunderbolt to Ethernet Adapter
Bus 001 Device 002: ID 8087:8000 Intel Corp. Integrated Rate Matching Hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Use Case 2: Listing the USB Hierarchy as a Tree

Code:

lsusb -t

Motivation:

Observing the hierarchy and organization of USB devices in a tree format can be crucial for understanding the structure of USB buses and how devices are connected. This organizational hierarchy helps in visualizing the physical USB ports and their associated devices. This is particularly useful for complex systems with multiple USB hubs and devices, allowing users to easily identify how devices are connected.

Explanation:

  • -t: This option tells lsusb to output its findings in a tree view, representing the hierarchy of USB buses and devices. It helps in visualizing the connection paths and identifying which devices are linked to specific hubs.

Example Output:

/:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/1p, 5000M
    |__ Port 1: Dev 3, If 0, Class=Vendor Specific Class, Driver=, 5000M
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/8p, 480M
    |__ Port 3: Dev 2, If 0, Class=Mass Storage, Driver=usb-storage, 480M

Use Case 3: Listing Verbose Information about USB Devices

Code:

lsusb --verbose

Motivation:

For more in-depth troubleshooting or device analysis, users may require detailed information concerning each USB device. The --verbose option delivers comprehensive data, including all known descriptors for devices, configurations, interfaces, and endpoints. This detail is invaluable when diagnosing complex issues or understanding the capabilities and features of connected USB devices.

Explanation:

  • --verbose: This option enhances the output detail from lsusb, allowing inspection of descriptors, URLs, supported speeds, and more. It’s indispensable for developers and technicians who need a nuanced understanding of device architecture and performance.

Example Output:

Bus 002 Device 003: ID 05ac:027a Apple, Inc. Thunderbolt to Ethernet Adapter
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.10
  bDeviceClass            2 Communications
  ...

Use Case 4: Listing Detailed Information About a Specific USB Device

Code:

lsusb --verbose -s 002:003

Motivation:

When faced with issues or when seeking to understand the specifications of a particular USB device, it can be helpful to target that specific device for detailed information. By specifying the bus and device number, users can zoom in on a single device in the verbose mode, allowing for a focused analysis without the clutter of information from other devices.

Explanation:

  • --verbose: Provides detailed information about the specified device.
  • -s 002:003: Specifies the bus and device number of the USB device. The numbers can be attained from running the lsusb command without arguments, which lists all devices and their corresponding numbers.

Example Output:

Bus 002 Device 003: ID 05ac:027a Apple, Inc. Thunderbolt to Ethernet Adapter
Device Descriptor:
  bLength                18
  bDescriptorType         1
  ...

Use Case 5: Listing Devices with a Specified Vendor and Product ID Only

Code:

lsusb -d 05ac:027a

Motivation:

There may be circumstances in which one needs to identify USB devices from a specific vendor or with particular product identifiers. For instance, this is useful in environments with many devices, where identifying devices by model or manufacturer is crucial—such as in networked office setups or for managing multiple peripheral devices in large labs.

Explanation:

  • -d 05ac:027a: The -d option specifies both the vendor ID (05ac, typically indicating Apple, Inc.) and the product ID (027a) to filter the list of USB devices to return only those matching these criteria.

Example Output:

Bus 002 Device 003: ID 05ac:027a Apple, Inc. Thunderbolt to Ethernet Adapter

Conclusion

The lsusb command is an essential tool for managing and troubleshooting USB devices on Linux systems. By adeptly utilizing its various options, users can quickly and efficiently obtain information about USB connections, analyze the system’s hardware architecture, and diagnose issues with connected devices. Whether you need a simple device list or require in-depth information on intricate USB setups, lsusb has the flexibility to meet a range of user needs.

Related Posts

How to Use the Command 'zramctl' (with Examples)

How to Use the Command 'zramctl' (with Examples)

zramctl is a command-line utility for setting up and controlling zram devices on Linux systems.

Read More
How to Use the Command 'sstat' (with examples)

How to Use the Command 'sstat' (with examples)

‘sstat’ is a command-line tool provided by SLURM (Simple Linux Utility for Resource Management), which is an open-source workload manager.

Read More
How to Use the Command 'gbp' (with Examples)

How to Use the Command 'gbp' (with Examples)

The gbp, or git-buildpackage, is a command-line tool specifically designed to integrate the Debian package build system with Git.

Read More