Introduction
In Linux systems, hardware management is a fundamental task for administrators and advanced users. Knowing which USB devices are connected allows diagnosing problems, configuring peripherals, and optimizing system performance.
What is lsusb?
The lsusb command belongs to the usbutils package and shows detailed information about USB buses and the devices connected to them. It uses the libusb library to read the USB tree structure exposed by the kernel.
Installation
In most modern distributions, usbutils comes pre-installed. If it is not present, simply run:
- Debian/Ubuntu:
sudo apt-get install usbutils - Fedora:
sudo dnf install usbutils - Arch Linux:
sudo pacman -S usbutils
Basic Usage
Running lsusb without arguments lists all detected USB devices:
lsusb
The typical output has the format:
Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Most Used Options
-vor--verbose: shows detailed descriptors for each device.-tor--tree: presents the information in tree form, showing the hierarchy of hubs and ports.-s [[bus]:][dev]: filters the output to a specific bus or device.-d [vendor]:[product]: shows only devices matching the vendor and product ID.-V: prints the version ofusbutils.
Practical Examples
- View the device tree:
lsusb -t - Get detailed information about a hub:
lsusb -v -s 001:002 - List only devices from a specific vendor (e.g., Logitech ID 046d):
lsusb -d 046d: - Save the output to a file for later analysis:
lsusb > usb_report.txt
Interpreting the Output
Each line begins with Bus XXX Device YYY: ID abcd:efgh Manufacturer Product Name. The first four hexadecimal digits (abcd) correspond to the vendor ID and the following (efgh) to the product ID. These IDs are essential for searching drivers or verifying compatibility.
When using -v, the output includes configuration descriptors, interfaces, endpoints, and features such as current consumption, speeds (Low, Full, High, SuperSpeed), and serial numbers.
Tips and Tricks
- Combine
lsusbwithgrepfor quick searching:lsusb | grep -i keyboard - Use
watch -n 1 lsusbto monitor changes in real time when connecting or disconnecting devices. - In administration scripts, check for the presence of a device before executing actions:
if lsusb -d 046d:c52b > /dev/null; then echo 'Logitech mouse detected'; fi - Remember that some devices may appear multiple times due to composite functions (e.g., a webcam with a microphone).
Conclusion
The lsusb
This post is also available in ESPAÑOL.