You are helping the user view all connected USB devices with detailed information.
Display all connected USB devices with detailed information including device tree, vendor/product IDs, and speed capabilities. Use this to troubleshoot hardware detection issues, identify device types, and verify USB controller functionality.
/plugin marketplace add danielrosehill/linux-desktop-plugin/plugin install lan-manager@danielrosehillYou are helping the user view all connected USB devices with detailed information.
Basic USB device listing:
# Simple list
lsusb
# With tree structure showing hubs
lsusb -t
# Verbose output
lsusb -v | less
Detailed information for each device:
# Iterate through all devices
for device in $(lsusb | awk '{print $2":"$4}' | sed 's/:$//' | tr ':' '/'); do
bus=$(echo $device | cut -d'/' -f1)
dev=$(echo $device | cut -d'/' -f2)
echo "=== Device: Bus $bus Device $dev ==="
lsusb -v -s $bus:$dev 2>/dev/null | head -30
echo ""
done
Show USB devices by type:
echo "=== Input Devices (Keyboards, Mice) ==="
lsusb | grep -iE "keyboard|mouse|input"
echo -e "\n=== Storage Devices ==="
lsusb | grep -iE "storage|disk|flash|card reader"
echo -e "\n=== Audio Devices ==="
lsusb | grep -iE "audio|sound|headset|microphone"
echo -e "\n=== Video Devices ==="
lsusb | grep -iE "camera|video|webcam"
echo -e "\n=== Bluetooth Adapters ==="
lsusb | grep -i bluetooth
echo -e "\n=== Network Adapters ==="
lsusb | grep -iE "network|ethernet|wifi|802.11"
USB device details from sysfs:
# List all USB devices with details
for dev in /sys/bus/usb/devices/*; do
if [ -f "$dev/manufacturer" ] && [ -f "$dev/product" ]; then
echo "Device: $(cat $dev/product 2>/dev/null)"
echo "Manufacturer: $(cat $dev/manufacturer 2>/dev/null)"
echo "Serial: $(cat $dev/serial 2>/dev/null)"
echo "Speed: $(cat $dev/speed 2>/dev/null) Mbps"
echo "---"
fi
done
USB device mount points and block devices:
# Show USB storage devices
lsblk -o NAME,SIZE,TYPE,MOUNTPOINT,MODEL | grep -i usb
# USB device names in /dev
ls -l /dev/sd* /dev/nvme* 2>/dev/null | grep -E "^b"
# Detailed block device info
lsblk -f
USB power consumption:
# Check power usage
for device in /sys/bus/usb/devices/*/power/active_duration; do
dev=$(dirname $(dirname $device))
if [ -f "$dev/product" ]; then
echo "$(cat $dev/product): Power: $(cat $dev/power/level) Active: $(cat $device)ms"
fi
done
USB device speed and capabilities:
# USB version and speed
for dev in /sys/bus/usb/devices/usb*; do
echo "USB Bus $(basename $dev):"
echo " Version: $(cat $dev/version 2>/dev/null)"
echo " Speed: $(cat $dev/speed 2>/dev/null) Mbps"
echo " Max Child: $(cat $dev/maxchild 2>/dev/null) ports"
echo ""
done
Create formatted device report:
cat > /tmp/usb-devices.txt << EOF
USB Devices Report
==================
Generated: $(date)
Hostname: $(hostname)
=== Connected USB Devices ===
EOF
lsusb >> /tmp/usb-devices.txt
echo -e "\n=== USB Device Tree ===" >> /tmp/usb-devices.txt
lsusb -t >> /tmp/usb-devices.txt
echo -e "\n=== USB Storage Devices ===" >> /tmp/usb-devices.txt
lsblk -o NAME,SIZE,TYPE,MOUNTPOINT,MODEL | grep -i usb >> /tmp/usb-devices.txt
echo -e "\n=== USB Device Details ===" >> /tmp/usb-devices.txt
usb-devices >> /tmp/usb-devices.txt
cat /tmp/usb-devices.txt
Check USB controller info:
# List USB controllers
lspci | grep -i usb
# Detailed controller info
for controller in $(lspci | grep -i usb | cut -d' ' -f1); do
echo "=== Controller $controller ==="
lspci -v -s $controller | head -20
echo ""
done
Monitor USB events in real-time:
# Watch for USB connect/disconnect
udevadm monitor --subsystem-match=usb
# Or use dmesg
dmesg -w | grep -i usb
Check USB autosuspend settings:
# Check which devices have autosuspend enabled
for dev in /sys/bus/usb/devices/*/power/control; do
device=$(dirname $(dirname $dev))
if [ -f "$device/product" ]; then
echo "$(cat $device/product): $(cat $dev)"
fi
done
Find USB device by vendor/product ID:
# Search by ID
# Example: Find device 046d:c52b
lsusb -d 046d:c52b -v
# Find all devices from vendor
lsusb -d 046d: # Logitech devices
Check USB permissions:
# Show device permissions
ls -l /dev/bus/usb/*/* | head -20
# Find device files for specific bus
ls -l /dev/bus/usb/001/
# Check udev rules for USB
ls -l /etc/udev/rules.d/*usb*
Create a nice summary:
cat > /tmp/usb-summary.sh << 'EOF'
#!/bin/bash
echo "╔════════════════════════════════════════════════════════╗"
echo "║ USB Devices Summary ║"
echo "╚════════════════════════════════════════════════════════╝"
echo ""
echo "Total USB devices: $(lsusb | wc -l)"
echo ""
echo "--- By Type ---"
echo "Input devices: $(lsusb | grep -ciE 'keyboard|mouse|input')"
echo "Storage devices: $(lsusb | grep -ciE 'storage|disk|flash')"
echo "Audio devices: $(lsusb | grep -ci audio)"
echo "Video devices: $(lsusb | grep -ciE 'camera|video')"
echo "Network devices: $(lsusb | grep -ciE 'network|ethernet|wifi')"
echo "Bluetooth adapters: $(lsusb | grep -ci bluetooth)"
echo ""
echo "--- USB Controllers ---"
lspci | grep -i usb
echo ""
echo "--- Storage Devices ---"
lsblk -o NAME,SIZE,TYPE,MOUNTPOINT | grep -A 10 -E "^sd|^nvme"
echo ""
echo "--- Recent USB Events ---"
journalctl -k --since "1 hour ago" | grep -i usb | tail -10
EOF
chmod +x /tmp/usb-summary.sh
bash /tmp/usb-summary.sh
Device not detected:
# Check kernel messages
dmesg | grep -i usb | tail -20
# Check if ports working
cat /sys/kernel/debug/usb/devices
# Rescan USB bus
echo 1 | sudo tee /sys/bus/pci/rescan
Device keeps disconnecting:
# Disable autosuspend for problematic device
# Find device path
device_path=$(find /sys/bus/usb/devices/ -name "DEVICE_NAME*")
# Disable autosuspend
echo 'on' | sudo tee $device_path/power/control
Permission denied:
# Add user to plugdev group
sudo usermod -aG plugdev $USER
# Create udev rule for device
# /etc/udev/rules.d/50-mydevice.rules
# SUBSYSTEM=="usb", ATTR{idVendor}=="1234", ATTR{idProduct}=="5678", MODE="0666"
# Create detailed report
usb-devices > ~/usb-devices-$(date +%Y%m%d).txt
# Or with lsusb
lsusb -v > ~/usb-devices-verbose-$(date +%Y%m%d).txt
USB 1.1: 12 Mbps (Full Speed)
USB 2.0: 480 Mbps (High Speed)
USB 3.0: 5 Gbps (SuperSpeed)
USB 3.1: 10 Gbps (SuperSpeed+)
USB 3.2: 20 Gbps
USB 4.0: 40 Gbps
Vendor ID format: 046d (Logitech), 8086 (Intel), etc.
Product ID format: c52b (specific device model)
USB device path: /dev/bus/usb/BUS/DEVICE
Use usbutils package for lsusb and usb-devices commands