Introduction
In this hands-on lab, you'll discover how to effectively use the lsusb
command within a Linux environment to monitor and manage your connected USB devices. As a systemadmin, understanding your hardware is critical. The lsusb
command offers a wealth of information concerning USB devices, including their bus and device assignments, vendor and product identification numbers, device classification, and various other pertinent details. Throughout this practical exercise, you will delve into the fundamental application of the lsusb
command and acquire the ability to pinpoint specific USB device attributes. The skills gained in this lab will empower you to efficiently diagnose and oversee USB devices operating within your Linux system.
Understand the Purpose of lsusb Command
This section focuses on clarifying the role and fundamental operation of the lsusb
command within Linux. As a vital tool for any systemadmin, lsusb
enables you to enumerate and examine details of the USB peripherals attached to your machine.
The lsusb
command delivers the following crucial data about USB devices:
- USB device bus and device numbering
- USB device Vendor ID and Product ID
- Information on device class, subclass, and communication protocols
- Extensive device specifications, like manufacturer details, product name, and unique serial numbers
To invoke the lsusb
command, simply type 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 presented output indicates that the system has multiple USB devices connected, including root hubs supporting USB 2.0 and USB 3.0 standards.
We will explore advanced usage of the lsusb
command in the subsequent stage to extract precise USB device details.
Explore Basic Usage of lsusb Command
This part delves into the standard usage of the lsusb
command for gaining deeper insights into the connected USB devices.
Let's initiate by using the lsusb
command with the -v
(verbose) option to present a comprehensive overview of each USB device:
$ lsusb -v
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
[...]
The resulting output now encompasses more in-depth specifications like the device class, subclass, protocols, and extra data regarding each USB device.
Moreover, you can utilize the lsusb
command to pinpoint a particular USB device using its vendor and product ID. As an illustration, to gather information concerning a USB mouse, the following command can be employed:
$ 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 execution displays comprehensive details pertaining to the USB mouse, encompassing its vendor and product identifiers, device category, and the report descriptor.
By grasping the fundamental operation of the lsusb
command, you gain the aptitude to proficiently identify and rectify issues tied to USB devices on your Linux system.
Identify USB Device Information with lsusb
In this concluding phase, we will acquire proficiency in extracting intricate data about USB devices attached to your system through the lsusb
command.
To begin, let's generate a listing of all 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 highlights the bus number, device number, vendor ID, and product ID for each recognized USB device.
To delve into the specifics of a particular USB device, we can employ the lsusb -v
command, supplying the vendor and product identifiers. For example, to retrieve information regarding a USB mouse exhibiting the vendor ID 046d and product ID c077, the subsequent command can be executed:
$ 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
[...]
The above output presents a comprehensive account of the USB mouse, detailing its device descriptor, configuration descriptor, and HID report descriptor.
By wielding the lsusb
command in conjunction with its diverse options, you can adeptly recognize and address complications related to USB devices on your Linux system, streamlining your tasks as a systemadmin, even potentially needing root access in some scenarios.
Summary
Within this lab, we explored the essence and foundational usage of the lsusb command in Linux. This command empowers you to enumerate the USB devices connected to your system, revealing essential properties such as the bus number, device number, vendor ID, product ID, device class, subclass, and protocol. Leveraging the lsusb command with the -v option unlocks access to more granular insights about each USB device. Furthermore, you can precisely locate a USB device by specifying its vendor and product IDs using the lsusb command.