34

I have a number of USB ports on my computer, some USB 2 and some USB 3. I want to plug a device into a USB 3 port. Unfortunately, they're all black so I can't use the usual "USB 3.0 ports are blue" rule of thumb.

This is a Linux box, so is there any way to know if I've plugged the device into a USB 3 port, maybe using some command line utility or by inspecting some kernel messages?

4 Answers4

35

You can determine the USB version by running lsusb

  • 12M = 12MBit/s = USB1
  • 480M = 480MBit/s = USB2
  • 5000M = 5000MBit/s = USB3.0 aka USB3.1 gen. 1
  • 10000M = 10000MBit/s = USB3.1 gen. 2

Try using something like:

lsusb -D /dev/bus/usb/002/005

The USB 2.00/3.00 corresponds to USB 2.0 / 3.0

Perhaps even try using lsusb -t

The first conversion chart will help you determine the USB version.

Take a look at THIS link for more examples.

db-inf
  • 141
16

As @MarkHu and @Matthew noted, the currently accepted answer (lsusb -D) has the potential to be misleading, since it lists the speed(s) which are supported by the device, not the actual speed. Or, at least I couldn't use its output to find current device speed.

Does it matter whether it's a USB 3 port if it doesn't negotiate USB 3 speeds?

Looking at the actual speed on a Linux box is a bit of an hassle; lsusb doesn't seem to offer, right now, a solution out of the box. That's what I found to be working. First, list all your connected devices and hubs to identify your device:

> lsusb
Bus 002 Device 003: ID 0424:2660 Microchip Technology, Inc. (formerly SMSC) Hub
Bus 002 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 005 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 004 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 004: ID 1058:25ee Western Digital Technologies, Inc.
Bus 001 Device 003: ID 051d:0002 American Power Conversion Uninterruptible Power Supply
Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

In my case, I'm looking at the speed for my external WD MyBook disk. Hence the interesting line is:

Bus 001 Device 004: ID 1058:25ee Western Digital Technologies, Inc.

But, it seems that the "Bus 001 Device 004" part isn't useful to us in order to find the current device speed. Instead, we need the two colon-separated numbers 1058:25ee, the vendor id and product id for such device.

You should now check the /sys/devices directory for the contents of the idVendor file, looking for the vendor id from above (replace 1058 with your own vendor id)

> find /sys/devices/ -name idVendor -print -exec cat {} \; | grep -B 1 1058
./pci0000:00/0000:00:1a.0/usb1/1-1/1-1.6/idVendor
1058

Now take the output path above here and replace idVendor with speed and look at its contents:

> cat ./pci0000:00/0000:00:1a.0/usb1/1-1/1-1.6/speed
480

This way you're discovering a 480Mbps USB 2.0 connection.

If you've got multiple connected devices, you may check idProduct contents as well. If you've got multiple identical devices, look for the contents of serial as well.

8

My experience is that the lsusb -D command can be a misleading if it reports "capabilities" not currently enabled by the type of jack into which your device is plugged. See below example of filtered output (the entire output of sudo lsusb -D ${USB_DEVICE_PATH} was 80+ lines). In the this example, I deduce bcdUSB 3.00 should imply Device can operate at SuperSpeed (5Gbps) --though that line was still present when I plugged in my drive to a USB 2 jack for comparison.

$ lsusb -D /dev/bus/usb/007/003 | egrep -i 'usb|speed|version|Mbps|gbps|id|speed'

Device: ID 174c:1153 ASMedia Technology Inc. ASM2115 SATA 6Gb/s bridge bcdUSB 3.00 idVendor 0x174c ASMedia Technology Inc. idProduct 0x1153 ASM2115 SATA 6Gb/s bridge

SuperSpeed USB Device Capability: wSpeedsSupported 0x000e Device can operate at Full Speed (12Mbps) Device can operate at High Speed (480Mbps) Device can operate at SuperSpeed (5Gbps) Lowest fully-functional device speed is Full Speed (12Mbps)

Note also that the idProduct line contained some advisory/marketing text about 6Gb/s which should not be interpreted as an attainable speed.

Alternate short command that might be more useful:

$ sudo lsusb -t | egrep -i "storage" -B1

/: Bus 07.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/2p, 5000M |__ Port 1: Dev 3, If 0, Class=Mass Storage, Driver=usb-storage, 5000M

MarkHu
  • 741
2

If you want to find out the actual speed of the connection (as opposed to the capacities reported by lsusb), you can read the "speed" files from /sys/devices. Assuming you can connect and disconnect the device freely, you can use the following script to make the process semi-automatic. Another script to get a full list is described below.

  1. Unplug the device
  2. Start the script. It will ask to connect the device and press ENTER
  3. Connect the device
  4. Press ENTER
  5. The script reports the corresponding connection speed:
/sys/devices/pci0000:00/0000:00:14.0/usb1/1-2/speed    480

Or:

/sys/devices/pci0000:00/0000:00:14.0/usb2/2-3/2-3.3/2-3.3.1/speed    5000

Here are the possible speeds, in Mbit/s:

  • 1.5 = USB 1.0/Low-Speed
  • 12 = USB 1.1/Full-Speed
  • 480 = USB 2.0/Hi-Speed
  • 5000 = USB 3.0/SuperSpeed
  • 10000 = USB 3.1/SuperSpeed

And here is the script. I call it usbspeed-get:

#!/bin/bash
# https://superuser.com/a/1780101/
set -e

LIST1=mktemp LIST2=mktemp echo "Getting list of current devices..." find /sys/devices -name speed | sort > "$LIST1" echo -n "Now plug the relevant USB device and press ENTER..." read dummy find /sys/devices -name speed | sort > "$LIST2"

comm -3 "$LIST1" "$LIST2" | while read f ; do echo -n "$f" " " cat "$f" done | column -t -s' '

rm "$LIST1" "$LIST2"

If you prefer to have an overview of all devices and according speeds, you can use the following script. I call it usbspeed-list.

#!/bin/bash
# https://superuser.com/a/1780101/

sep="|" find /sys/devices -name speed | grep usb | while read f ; do dir=dirname "$f" for name in speed manufacturer product ; do cat "$dir/$name" 2>/dev/null | tr '\n' ' ' echo -n "$sep" done echo -n "$dir$sep" echo done | column -t --separator "$sep"

By default it will output the devices in the order they are found in /sys/devices. If you want to sort them by speed, you can combine it with sort -n:

usbspeed-list | sort -n
1.5                                        Keyboard                    /sys/devices/pci0000:00/0000:00:14.0/usb1/1-3/1-3.4/1-3.4.4/1-3.4.4.2              
1.5     Texas Instruments                  TPS65983B                   /sys/devices/pci0000:00/0000:00:14.0/usb1/1-3/1-3.3/1-3.3.2                        
12      Silicon Laboratories               EFM8 HID ISP                /sys/devices/pci0000:00/0000:00:14.0/usb1/1-3/1-3.3/1-3.3.3                        
12                                                                     /sys/devices/pci0000:00/0000:00:14.0/usb1/1-14                                     
480     GenesysLogic                       USB2.0 Hub                  /sys/devices/pci0000:00/0000:00:14.0/usb1/1-3/1-3.4/1-3.4.4                        
480     GenesysLogic                       USB2.0 Hub                  /sys/devices/pci0000:00/0000:00:14.0/usb1/1-3/1-3.4/1-3.4.4/1-3.4.4.4              
480     Linux 5.19.0-38-generic xhci-hcd   xHCI Host Controller        /sys/devices/pci0000:00/0000:00:14.0/usb1                                          
480     Sonix Technology Co., Ltd.         USB2.0 Camera               /sys/devices/pci0000:00/0000:00:14.0/usb1/1-8                                      
480                                        USB2.0 Hub                  /sys/devices/pci0000:00/0000:00:14.0/usb1/1-3/1-3.4/1-3.4.4/1-3.4.4.1              
480     VIA Labs, Inc.                     USB2.0 Hub                  /sys/devices/pci0000:00/0000:00:14.0/usb1/1-3                                      
480     VIA Labs, Inc.                     USB2.0 Hub                  /sys/devices/pci0000:00/0000:00:14.0/usb1/1-3/1-3.3                                
480     VIA Labs, Inc.                     USB2.0 Hub                  /sys/devices/pci0000:00/0000:00:14.0/usb1/1-3/1-3.4                                
1000                                                                   /sys/devices/pci0000:00/0000:00:14.0/usb2/2-3/2-3.1/2-3.1:1.5/net/enx806d9711f2b1  
5000    DisplayLink                        USB-C Triple-4K Dock        /sys/devices/pci0000:00/0000:00:14.0/usb2/2-3/2-3.1                                
5000    Generic                            USB Storage                 /sys/devices/pci0000:00/0000:00:14.0/usb2/2-3/2-3.4/2-3.4.4/2-3.4.4.4/2-3.4.4.4.4  
5000    GenesysLogic                       USB3.0 Hub                  /sys/devices/pci0000:00/0000:00:14.0/usb2/2-3/2-3.4/2-3.4.4                        
5000    GenesysLogic                       USB3.0 Hub                  /sys/devices/pci0000:00/0000:00:14.0/usb2/2-3/2-3.4/2-3.4.4/2-3.4.4.4              
5000    Prolific Technology Inc.           ATAPI-6 Bridge Controller   /sys/devices/pci0000:00/0000:00:14.0/usb2/2-2                                      
5000    Seagate                            BUP Portable                /sys/devices/pci0000:00/0000:00:14.0/usb2/2-3/2-3.2                                
5000    Space keys                         USB3.1 Storage Device       /sys/devices/pci0000:00/0000:00:14.0/usb2/2-3/2-3.3/2-3.3.1                        
5000    VIA Labs, Inc.                     USB3.0 Hub                  /sys/devices/pci0000:00/0000:00:14.0/usb2/2-3                                      
5000    VIA Labs, Inc.                     USB3.0 Hub                  /sys/devices/pci0000:00/0000:00:14.0/usb2/2-3/2-3.3                                
5000    VIA Labs, Inc.                     USB3.0 Hub                  /sys/devices/pci0000:00/0000:00:14.0/usb2/2-3/2-3.4                                
10000   Linux 5.19.0-38-generic xhci-hcd   xHCI Host Controller        /sys/devices/pci0000:00/0000:00:14.0/usb2 

Here the keyboard is connected at a very low speed (1.5), which is normal, and the USB hard disk dock (ATAPI-6 Bridge Controller) is connected at 5000MBit/s.

Another way to list the devices and their speed is the "usb-devices" script provided by usbutils and installed by default by some distributions. It is more generic but also very verbose. It reports the speed on the first line of the device description:

T:  Bus=02 Lev=01 Prnt=01 Port=01 Cnt=01 Dev#= 44 Spd=5000 MxCh= 0
D:  Ver= 3.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 9 #Cfgs=  1
P:  Vendor=067b ProdID=2773 Rev=01.00
S:  Manufacturer=Prolific Technology Inc.
S:  Product=ATAPI-6 Bridge Controller
S:  SerialNumber=0123456789000000005
C:  #Ifs= 1 Cfg#= 1 Atr=c0 MxPwr=96mA
I:  If#= 0 Alt= 0 #EPs= 2 Cls=08(stor.) Sub=06 Prot=50 Driver=usb-storage
E:  Ad=01(O) Atr=02(Bulk) MxPS=1024 Ivl=0ms
E:  Ad=84(I) Atr=02(Bulk) MxPS=1024 Ivl=0ms

Make sure that you use a recent version. The version provided with Ubuntu 22.04 does not list all devices.

plswork04
  • 223