Connected USB devices appear when you run `lsusb`, which queries the kernel’s USB subsystem for attached hardware. Knowing how to list usb devices in linux is a fundamental skill for troubleshooting, managing peripherals, or checking system compatibility. This guide covers every practical method, from simple commands to detailed hardware inspection, so you can quickly identify any USB device connected to your Linux machine.
Why Listing USB Devices Matters
You might need to check if a new keyboard, flash drive, or printer is recognized. Maybe a device isn’t working, and you want to see if the system sees it at all. Listing USB devices helps you verify connections, find device IDs for drivers, and understand your hardware setup without guessing.
Most methods use built-in tools that come with any Linux distribution. You don’t need to install extra software for basic checks. Let’s start with the simplest command.
How To List Usb Devices In Linux
The most common way is the `lsusb` command. Open your terminal and type:
lsusb
You’ll see output like this:
Bus 001 Device 004: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 002 Device 002: ID 046d:c077 Logitech, Inc. M105 Optical Mouse
Bus 002 Device 003: ID 0781:5583 SanDisk Corp. Ultra Fit
Each line shows a USB device. The bus number, device number, vendor and product ID (like 046d:c077), and a description. This is the fastest way to see all connected USB devices at once.
If you want more detail, add the `-v` flag for verbose mode. But be warned—it prints a lot of information per device.
lsusb -v
You can also filter by vendor ID or product ID. For example, to see only devices from Logitech:
lsusb -d 046d:
This lists all devices with vendor ID 046d.
Using Lsusb With Sudo
Some devices might not show full details without root privileges. Run `sudo lsusb -v` to get complete descriptors. This is helpful when debugging driver issues or checking power usage.
Using The Dmesg Command
The kernel log stores messages about hardware detection. When you plug in a USB device, `dmesg` records it. This method is great for seeing real-time events.
To view recent USB-related messages:
dmesg | grep -i usb
You’ll see lines like:
[ 1234.567890] usb 2-1: new high-speed USB device number 5 using ehci-pci
[ 1234.678901] usb 2-1: New USB device found, idVendor=0781, idProduct=5583
[ 1234.678902] usb 2-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
This shows when the device was detected, its speed, and identifiers. For live monitoring, use:
dmesg -w
Then plug in a USB device. New lines appear instantly.
Filtering Dmesg For Specific Devices
If you know the vendor ID, grep for it:
dmesg | grep "0781"
This narrows down to SanDisk devices in our example.
Checking The /Sys And /Proc Filesystems
Linux exposes hardware information through virtual filesystems. You can browse `/sys/bus/usb/devices/` for a tree view.
List all USB device directories:
ls /sys/bus/usb/devices/
Each directory like `2-1:1.0` represents a device or interface. Inside, you’ll find files like `idVendor`, `idProduct`, `manufacturer`, `product`, and `serial`.
To quickly see vendor and product IDs for all devices:
for dev in /sys/bus/usb/devices/*/idVendor; do echo "$(cat $dev):$(cat ${dev%idVendor}idProduct)"; done
This loops through each device and prints the IDs.
Using Udevadm For Detailed Info
The `udevadm` command queries the udev database. For a specific device path:
udevadm info --query=all --name=/dev/bus/usb/001/004
Replace the bus and device numbers from `lsusb` output. This gives you properties like driver, subsystem, and symlinks.
Listing Block Devices With Lsblk
USB storage devices like flash drives appear as block devices. The `lsblk` command shows all block devices, including USB ones.
lsblk
Output:
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 238.5G 0 disk
├─sda1 8:1 0 512M 0 part /boot/efi
└─sda2 8:2 0 238G 0 part /
sdb 8:16 1 14.9G 0 disk
└─sdb1 8:17 1 14.9G 0 part /media/usb
Here, `sdb` is a USB flash drive. The `RM` column shows 1 for removable devices. You can filter with:
lsblk -o NAME,SIZE,TYPE,MOUNTPOINT,TRAN
The `TRAN` column shows transport type (usb, sata, etc.). This quickly identifies USB storage.
Using Fdisk To See USB Disks
For partition details:
sudo fdisk -l /dev/sdb
Replace `sdb` with your device name. This shows partition tables and sizes.
Graphical Tools For USB Devices
If you prefer a GUI, most desktop environments include a disk utility. On GNOME, open “Disks” (gnome-disk-utility). It lists all drives, including USB ones, with model, size, and health info.
For a dedicated USB viewer, install `usbview`:
sudo apt install usbview
Then run `usbview`. It shows a tree of USB buses and devices with detailed descriptors. This is useful for visual learners.
Using The Usb.ids Database
The `lsusb` command uses a database file at `/usr/share/usb.ids` to translate vendor and product IDs to human-readable names. If you see “Unknown” devices, the database might be outdated.
Update it with:
sudo update-usbids
Or download the latest file manually from linux-usb.org.
Troubleshooting Common Issues
Sometimes a USB device doesn’t appear in `lsusb`. Check these steps:
- Try a different USB port. Some ports might be disabled or faulty.
- Check power supply. USB hubs without external power might not provide enough current.
- Run `dmesg` right after plugging in to see if the kernel detects it.
- Look for driver messages. If the device isn’t supported, you’ll see errors.
- Use `sudo lsusb -v` to see if the device is there but not enumerated correctly.
If the device shows in `dmesg` but not `lsusb`, it might be a driver issue. Search for the vendor/product ID online to find compatible drivers.
Checking USB Speed And Version
To see if a device is USB 2.0, 3.0, or higher, look at the `lsusb -t` output:
lsusb -t
This shows a tree with speed indicators:
/: Bus 02.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/6p, 5000M
|__ Port 2: Dev 2, If 0, Class=Mass Storage, Driver=usb-storage, 5000M
5000M means USB 3.0 (5 Gbps). 480M is USB 2.0. 12M is USB 1.1.
Scripting USB Device Detection
You can write a simple script to monitor USB changes. Use `udevadm monitor`:
udevadm monitor --property --subsystem-match=usb
This prints events when devices are added or removed. Combine with `grep` to filter.
For a custom script, parse `/sys/bus/usb/devices/` periodically. Here’s a bash example:
#!/bin/bash
while true; do
for dev in /sys/bus/usb/devices/*/product; do
echo "$(cat $dev)"
done
sleep 5
done
This prints product names every 5 seconds. Adjust as needed.
Understanding USB Device Hierarchy
USB devices are organized in a tree. The root hub connects to the computer. Hubs can have multiple ports, and devices connect to ports. `lsusb -t` shows this hierarchy visually.
Each device has a unique bus and device number. These change after reboot or reconnection. The vendor/product ID and serial number remain constant.
For persistent identification, use the serial number from `lsusb -v` or `/sys/bus/usb/devices/*/serial`. This helps when writing udev rules.
Creating Udev Rules For USB Devices
You can assign fixed names to USB devices using udev rules. First, get the device attributes:
udevadm info -a -n /dev/bus/usb/001/004
Then create a rule file in `/etc/udev/rules.d/`. For example, to name a flash drive “myusb”:
SUBSYSTEM=="usb", ATTR{idVendor}=="0781", ATTR{idProduct}=="5583", SYMLINK+="myusb"
Reload rules with `sudo udevadm control –reload-rules`.
Comparing Different Methods
Each method has strengths:
- lsusb: Quick overview, easy to read.
- dmesg: Shows kernel events and errors.
- /sys: Raw data for scripting.
- lsblk: Storage-specific info.
- usbview: Graphical tree.
Choose based on your need. For daily checks, `lsusb` is enough. For debugging, combine `dmesg` and `lsusb -v`.
Common USB Device Types And Their Identifiers
Here are typical devices and what to look for:
| Device Type | Typical Vendor ID | Common Product ID |
|---|---|---|
| Flash drive | 0781 (SanDisk) | 5583 |
| Mouse | 046d (Logitech) | c077 |
| Keyboard | 045e (Microsoft) | 0745 |
| Webcam | 046d (Logitech) | 0825 |
These IDs help identify unknown devices.
Using Lsusb With Other Tools
Combine `lsusb` with `grep` for filtering. For example, list only devices with “Logitech” in the description:
lsusb | grep -i logitech
Or count devices:
lsusb | wc -l
This gives the total number of USB devices.
Exporting USB Device List To A File
Save the list for later analysis:
lsusb > usb_devices.txt
Or with verbose output:
lsusb -v > usb_details.txt
This is useful for documentation or sharing with support forums.
Frequently Asked Questions
How do I list USB devices in Linux without lsusb?
You can use `dmesg | grep -i usb`, check `/sys/bus/usb/devices/`, or use `lsblk` for storage devices. All these work without `lsusb` installed.
Why doesn’t my USB device show up in lsusb?
Possible reasons: faulty port, insufficient power, missing driver, or the device is not USB (e.g., internal SATA). Run `dmesg` after plugging it in to see kernel messages.
How can I see USB device details like serial number?
Use `lsusb -v` and look for `iSerial` field. Or check `/sys/bus/usb/devices/*/serial` for the serial number directly.
What is the difference between lsusb and lsblk?
`lsusb` lists all USB devices regardless of type. `lsblk` shows block devices (storage) including USB drives. Use both for complete picture.
Can I list USB devices in real-time?
Yes, use `dmesg -w` to watch kernel messages, or `udevadm monitor` for udev events. These show devices as they are connected or removed.
Advanced: Using Python To List USB Devices
For programmers, the `pyusb` library provides programmatic access. Install it with:
pip install pyusb
Then write a script:
import usb.core
import usb.util
devices = usb.core.find(find_all=True)
for dev in devices:
print(dev)
This lists all USB devices with their descriptors. You can filter by vendor ID, product ID, or other attributes.
Using Libusb For Low-Level Access
The `libusb` library (used by pyusb) gives direct control. Install development packages:
sudo apt install libusb-1.0-0-dev
Then use C or Python to enumerate devices. This is advanced but powerful for custom applications.
Checking USB Power Consumption
Some USB devices draw too much power. Check with `lsusb -v` and look for `bMaxPower` field. Values are in milliamps (mA). A typical port provides 500mA for USB 2.0 and 900mA for USB 3.0.
If a device reports higher than available, it might not work properly. Use a powered hub in such cases.
Final Tips For USB Device Management
Keep your USB ID database updated. Regularly run `sudo update-usbids`. This ensures `lsusb` shows correct names.
For persistent device names, use udev rules. This is especially useful for embedded systems or servers where devices need fixed paths.
Always safely remove USB storage with `umount` before unplugging to avoid data corruption. Use `sync` to flush buffers.
Now you have multiple ways to list USB devices in Linux. Start with `lsusb` for quick checks, `dmesg` for troubleshooting, and `/sys` for scripting. Each method gives you a different view of your USB hardware.
Remember that USB devices can be tricky sometimes. If something doesn’t show up, try a different port, check power, and look at kernel messages. With these tools, you’ll always know what’s connected to your Linux system.