Today we will see how to list USB devices in Linux and their properties such as speed, BUS, class, type details etc. This is part of our on going hardware detection series. We already covered following stuff.
Get BIOS, Firmware, Hardware And Drivers Details in Linux/Unix
What is dmesg command and how to use it in Linux/Unix?
Find hardware info with lshw, hardinfo, sysinfo Linux/Unix commands
Find PCI hardware details using lspci command in Linux
What is USB?
USB(Universal Serial Bus) is a stranded developed to replace different types of BUS’s available. This is a solution devices to eliminate vendor lock-down of hardware ports, so that BUS’s will be identical across different devices from different vendors. USB devices solve one more problem i.e. speeds. USB devices can reach up 5GB/s as of this writing where as PCI and serial devices have less speeds. Depending of USB firmware, it’s categorize in to USB 1.0, USB 2.0, USB 3.0. USB have competitor in the from of Thunderbolt interface.
As a Linux User/administrator we should know USB bus details as well as devices connected. In this post we will see how to use lsusb command to display different USB properties.
Learn lsusb command with examples
Example 1: List all the USB ports available
lsusb
Output:
Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub Bus 002 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub 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 001 Device 003: ID 05c8:021e Cheng Uei Precision Industry Co., Ltd (Foxlink) Bus 001 Device 007: ID 0cf3:3005 Atheros Communications, Inc. AR3011 Bluetooth Bus 002 Device 003: ID 0781:5567 San Disk Corp. Cruzer Blade
Let us try to understand above output in detail.
Bus 002 Device 003: ID 0781:5567 SanDisk Corp. Cruzer Blade
Bus 002 : This is bus number where SanDisk USB stick is attached.
Device 003: This is the third device attached to bus 002, the other two devices are “Linux Foundation 2.0 root hub” and ” Intel Corp. Integrated Rate Matching Hub”
ID 0781:5567 is the number given to this SanDisk, The number before : indicates the manufacture ID and number after : indicates device ID. To get more info on this visit Linux-USB site.
SanDisk Corp. Cruzer Blade is the name of manufacture and device name.
Example 2: Check how many USB ports available in your machine so that we can connect USB devices to these ports.
find /dev/bus/
Output:
/dev/bus/ /dev/bus/usb /dev/bus/usb/002 /dev/bus/usb/002/006 /dev/bus/usb/002/005 /dev/bus/usb/002/004 /dev/bus/usb/002/002 /dev/bus/usb/002/001 /dev/bus/usb/001 /dev/bus/usb/001/007 /dev/bus/usb/001/003 /dev/bus/usb/001/002 /dev/bus/usb/001/001
These ports may be internal or external to the system.
Example : Get detailed information of a USB device connected to a machine. Suppose I want to see information about /dev/bus/usb/002/005 device use below command
lsusb -D /dev/bus/usb/002/005
Output:
Device: ID 0951:1643 Kingston Technology Data Traveler G3 4GB Couldn't open device, some information will be missing Device Descriptor: bLength 18 bDescriptorType 1 bcdUSB 2.00 bDeviceClass 0 (Defined at Interface level) bDeviceSubClass 0 bDeviceProtocol 0 bMaxPacketSize0 64 idVendor 0x0951 Kingston Technology idProduct 0x1643 DataTraveler G3 4GB bcdDevice 1.00 iManufacturer 1 iProduct 2 iSerial 3 bNumConfigurations 1 Configuration Descriptor: bLength 9 bDescriptorType 2 wTotalLength 32 bNumInterfaces 1 bConfigurationValue 1 iConfiguration 0 bmAttributes 0x80 (Bus Powered) MaxPower 200mA Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 0 bAlternateSetting 0 bNumEndpoints 2 bInterfaceClass 8 Mass Storage bInterfaceSubClass 6 SCSI bInterfaceProtocol 80 Bulk-Only iInterface 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x81 EP 1 IN bmAttributes 2 Transfer Type Bulk Synch Type None Usage Type Data wMaxPacketSize 0x0200 1x 512 bytes bInterval 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x02 EP 2 OUT bmAttributes 2 Transfer Type Bulk Synch Type None Usage Type Data wMaxPacketSize 0x0200 1x 512 bytes bInterval 0
To know each of these types, click here.
Example 3: Get all the USB ports available and devices connected using verbose mode.
lsusb -v
Clipped output:
Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub Couldn't open device, some information will be missing Device Descriptor: bLength 18 bDescriptorType 1 bcdUSB 2.00 bDeviceClass 9 Hub bDeviceSubClass 0 Unused bDeviceProtocol 1 Single TT bMaxPacketSize0 64 idVendor 0x8087 Intel Corp. idProduct 0x0024 Integrated Rate Matching Hub bcdDevice 0.00 iManufacturer 0 iProduct 0 iSerial 0 bNumConfigurations 1 Configuration Descriptor: bLength 9 bDescriptorType 2 wTotalLength 25 bNumInterfaces 1 bConfigurationValue 1 iConfiguration 0 bmAttributes 0xe0 Self Powered Remote Wakeup MaxPower 0mA Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 0 bAlternateSetting 0 bNumEndpoints 1 bInterfaceClass 9 Hub bInterfaceSubClass 0 Unused bInterfaceProtocol 0 Full speed (or root) hub iInterface 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x81 EP 1 IN bmAttributes 3 Transfer Type Interrupt Synch Type None Usage Type Data wMaxPacketSize 0x0001 1x 1 bytes bInterval 12
Example 4: List all mass storage devices in your system.
lsusb -v | grep -Ei '(idVendor|Mass Storage)'
Output:
idVendor 0x2006 bInterfaceClass 8 Mass Storage idVendor 0x0781 SanDisk Corp. bInterfaceClass 8 Mass Storage idVendor 0x0951 Kingston Technology bInterfaceClass 8 Mass Storage
From the above output we can find that there are total three USB storage devices present on the machine.
Example 5: Find USB devices protocol version.
lsusb -v | grep -i bcdusb
Output:
bcdUSB 1.10 bcdUSB 2.00 bcdUSB 2.00 bcdUSB 2.00
Depending on the version, the speed varies. Below table give you clear idea about the speeds associated with these versions.
USB 1.10 | 12Mb/s |
USB 2.00 | 480Mb/s |
USB 3.00 | 5Gb/s |
Example 6: Find USB device supported speeds by using tree structure option
lsusb -t
Otuput:
2-1.1:1.1: No such file or directory /: Bus 02.Port 1: Dev 1, Class=root_hub, Driver=ehci_hcd/2p, 480M |__ Port 1: Dev 2, If 0, Class=hub, Driver=hub/6p, 480M |__ Port 1: Dev 6, If 0, Class=stor., Driver=usb-storage, 480M |__ Port 1: Dev 6, If 1, Class=vend., Driver=, 480M |__ Port 2: Dev 7, If 0, Class=stor., Driver=usb-storage, 480M |__ Port 3: Dev 5, If 0, Class=stor., Driver=usb-storage, 480M /: Bus 01.Port 1: Dev 1, Class=root_hub, Driver=ehci_hcd/2p, 480M |__ Port 1: Dev 2, If 0, Class=hub, Driver=hub/6p, 480M |__ Port 3: Dev 3, If 0, Class='bInterfaceClass 0x0e not yet handled', Driver=uvcvideo, 480M |__ Port 3: Dev 3, If 1, Class='bInterfaceClass 0x0e not yet handled', Driver=uvcvideo, 480M |__ Port 4: Dev 7, If 0, Class='bInterfaceClass 0xe0 not yet handled', Driver=btusb, 12M |__ Port 4: Dev 7, If 1, Class='bInterfaceClass 0xe0 not yet handled', Driver=btusb, 12M
In our next post we will see other hardware device properties.
Latest posts by Surendra Anne (see all)
- Docker: How to copy files to/from docker container - June 30, 2020
- Anisble: ERROR! unexpected parameter type in action:
Fix - June 29, 2020 - FREE: JOIN OUR DEVOPS TELEGRAM GROUPS - August 2, 2019
- Review: Whizlabs Practice Tests for AWS Certified Solutions Architect Professional (CSAP) - August 27, 2018
- How to use ohai/chef-shell to get node attributes - July 19, 2018