Linux lsusb Command with Practical Examples

LinuxLinuxBeginner
Practice Now

Introduction

In this lab, you will learn how to use the lsusb command in Linux to monitor and manage USB devices connected to your system. The lsusb command provides detailed information about USB devices, including their bus and device numbers, vendor and product IDs, device class, and other relevant details. Through this lab, you will explore the basic usage of the lsusb command and learn how to identify specific USB device information. The content covered in this lab will help you effectively troubleshoot and manage USB devices in your Linux environment.

Linux Commands Cheat Sheet


Skills Graph

%%%%{init: {'theme':'neutral'}}%%%% flowchart RL linux(("`Linux`")) -.-> linux/BasicFileOperationsGroup(["`Basic File Operations`"]) linux(("`Linux`")) -.-> linux/TextProcessingGroup(["`Text Processing`"]) linux(("`Linux`")) -.-> linux/SystemInformationandMonitoringGroup(["`System Information and Monitoring`"]) linux(("`Linux`")) -.-> linux/UserandGroupManagementGroup(["`User and Group Management`"]) linux/BasicFileOperationsGroup -.-> linux/ls("`Content Listing`") linux/BasicFileOperationsGroup -.-> linux/cat("`File Concatenating`") linux/TextProcessingGroup -.-> linux/grep("`Pattern Searching`") linux/SystemInformationandMonitoringGroup -.-> linux/uname("`System Information Displaying`") linux/UserandGroupManagementGroup -.-> linux/id("`User/Group ID Displaying`") subgraph Lab Skills linux/ls -.-> lab-422783{{"`Linux lsusb Command with Practical Examples`"}} linux/cat -.-> lab-422783{{"`Linux lsusb Command with Practical Examples`"}} linux/grep -.-> lab-422783{{"`Linux lsusb Command with Practical Examples`"}} linux/uname -.-> lab-422783{{"`Linux lsusb Command with Practical Examples`"}} linux/id -.-> lab-422783{{"`Linux lsusb Command with Practical Examples`"}} end

Understand the Purpose of lsusb Command

In this step, we will understand the purpose and basic usage of the lsusb command in Linux. The lsusb command is a powerful tool that allows you to list information about the USB devices connected to your system.

The lsusb command provides the following key information about USB devices:

  • Bus number and device number of the USB device
  • Vendor ID and Product ID of the USB device
  • Device class, subclass, and protocol information
  • Detailed information about the USB device, such as the manufacturer, product name, and serial number

To run the lsusb command, simply execute the following in your terminal:

$ lsusb
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 003 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 005 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 006 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub

Example output:

The output shows that there are several USB devices connected to the system, including root hubs for USB 2.0 and USB 3.0 interfaces.

In the next step, we will explore more advanced usage of the lsusb command to identify specific USB device information.

Explore Basic Usage of lsusb Command

In this step, we will explore the basic usage of the lsusb command to retrieve more detailed information about the USB devices connected to your system.

First, let's use the lsusb command with the -v (verbose) option to display more detailed information about each USB device:

$ lsusb -v
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
[...]

The output now includes additional details such as the device class, subclass, protocol, and other information about each USB device.

You can also use the lsusb command to search for a specific USB device by its vendor and product ID. For example, to find information about a USB mouse, you can use the following command:

$ lsusb -d 046d:c077
Bus 001 Device 003: ID 046d:c077 Logitech, Inc. M105 Optical Mouse
    Device Descriptor:
      bLength                18
      bDescriptorType         1
      bcdUSB               2.00
      bDeviceClass            0 (Defined at Interface level)
      bDeviceSubClass         0
      bDeviceProtocol         0
      bMaxPacketSize0        64
      idVendor           0x046d Logitech, Inc.
      idProduct          0xc077 M105 Optical Mouse
      bcdDevice            1.00
      iManufacturer           1 Logitech
      iProduct                2 M105 Optical Mouse
      iSerial                 0
      bNumConfigurations      1
      Configuration Descriptor:
        bLength                 9
        bDescriptorType         2
        wTotalLength           34
        bNumInterfaces          1
        bConfigurationValue     1
        iConfiguration          0
        bmAttributes         0x80
          (Bus Powered)
        MaxPower              100mA
        Interface Descriptor:
          bLength                 9
          bDescriptorType         4
          bInterfaceNumber        0
          bAlternateSetting       0
          bNumEndpoints           1
          bInterfaceClass         3 Human Interface Device
          bInterfaceSubClass      1 Boot Interface Subclass
          bInterfaceProtocol      2 Mouse
          iInterface              0
          HID Device Descriptor:
            bLength                 9
            bDescriptorType        33
            bcdHID               1.11
            bCountryCode            0 Not supported
            bNumDescriptors         1
            bDescriptorType        34 Report
            wDescriptorLength      71
          Report Descriptor: (length is 71)
            Item(Global): Usage Page, data= [ 0x01 ] 1 (Generic Desktop Controls)
            Item(Local): Usage, data= [ 0x02 ] 2 (Mouse)
            [...]

This command displays detailed information about the USB mouse, including its vendor and product ID, device class, and report descriptor.

By exploring the basic usage of the lsusb command, you can effectively identify and troubleshoot USB device-related issues on your Linux system.

Identify USB Device Information with lsusb

In this final step, we will learn how to use the lsusb command to identify detailed information about the USB devices connected to your system.

First, let's list all the USB devices connected to the system:

$ lsusb
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 003 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 005 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 006 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub

This output shows the bus number, device number, vendor ID, and product ID for each USB device.

To get more detailed information about a specific USB device, we can use the lsusb -v command and provide the vendor and product ID. For example, to get information about a USB mouse with vendor ID 046d and product ID c077, we can run:

$ lsusb -v -d 046d:c077
Bus 001 Device 003: ID 046d:c077 Logitech, Inc. M105 Optical Mouse
    Device Descriptor:
      bLength                18
      bDescriptorType         1
      bcdUSB               2.00
      bDeviceClass            0 (Defined at Interface level)
      bDeviceSubClass         0
      bDeviceProtocol         0
      bMaxPacketSize0        64
      idVendor           0x046d Logitech, Inc.
      idProduct          0xc077 M105 Optical Mouse
      bcdDevice            1.00
      iManufacturer           1 Logitech
      iProduct                2 M105 Optical Mouse
      iSerial                 0
      bNumConfigurations      1
      [...]

This output provides detailed information about the USB mouse, including its device descriptor, configuration descriptor, and HID report descriptor.

By using the lsusb command with various options, you can effectively identify and troubleshoot USB device-related issues on your Linux system.

Summary

In this lab, we learned the purpose and basic usage of the lsusb command in Linux. The lsusb command allows you to list information about the USB devices connected to your system, including the bus number, device number, vendor ID, product ID, device class, subclass, and protocol. You can use the lsusb command with the -v option to display more detailed information about each USB device. Additionally, you can search for a specific USB device by its vendor and product ID using the lsusb command.

Linux Commands Cheat Sheet

Other Linux Tutorials you may like