How to check speed of USB port and/or external device on Linux

So you got this brand new (or hopelessly old.. does not really matter for the purposes of this exercise, hehe) computer… It’s got some USB ports, but who knows what they are (USB 3.0? 2.0? 1.0?) ?

How can you check what kind of USB ports does your Linux box have? Alternatively – how can you check how fast a USB device is?

Let’s use an example…

First let’s list all USB devices:

$ lsusb
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
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 002 Device 003: ID 067b:2303 Prolific Technology, Inc. PL2303 Serial Port
Bus 002 Device 014: ID 0480:a007 Toshiba America Info. Systems, Inc.

Let’s say you want to find out how fast the Toshiba device is (which in this case is a USB 2.0 hard disk).

To list all of the USB devices’ info we can do $ lsusb -vvv but that will dump 4-5 screens of text – mostly details which we are not interested in. We want to limit the info to just the Toshiba device and we want to look for the bcdUSB param, which will give us the USB version.

As we can see from the first lsusb command – the ID of the device is 0480 (hex). We can use it to limit the display of info to just this device. And we will use grep to look for the bcdUSB string:

$ lsusb -d 0480: -vvv | grep -i -B5 -A5 bcdUSB
Bus 002 Device 014: ID 0480:a007 Toshiba America Info. Systems, Inc. 
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.10
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0        64
  idVendor           0x0480 Toshiba America Info. Systems, Inc.

So this tells us that the Toshiba drive is a USB 2.10 (USB-2) device.

To check all the other devices drop the device ID filter:

$ lsusb -vvv | grep -i -B5 -A5 bcdUSB

… or … better yet … search for just bcdUSB and “Bus 0” – this will filter just the lines with the name of each device and then the one with bcdUSB (which is the version):

$ lsusb  -vvv | grep -i 'Bus 0\|bcdUSB'
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
  bcdUSB               2.00
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
  bcdUSB               2.00
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
  bcdUSB               2.00
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
  bcdUSB               3.00
Couldn't open device, some information will be missing
Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
  bcdUSB               2.00
Bus 002 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
  bcdUSB               2.00
Bus 002 Device 003: ID 067b:2303 Prolific Technology, Inc. PL2303 Serial Port
  bcdUSB               1.10
Bus 002 Device 014: ID 0480:a007 Toshiba America Info. Systems, Inc. 
  bcdUSB               2.10

So… looking at the output, what can we determine about the USB ports provided by the computer and the USB devices attached to them?

On this computer I have 4 USB ports (Bus 001 to 004). Their USB versions/flavours are as follows: 3x USB 2.0 ports and 1x USB 3.0 port. Reading further down we can see the 2 entries for ‘Intel Corp. Integrated Rate Matching Hub’, and since I know that I have not attached any USB hubs to my computer, it tells me that these are built-in hubs. So in reality the machine has actually a lot more ports, most of them USB-2 (provided by the two hubs on Bus 001 and Bus 002, as well as one standalone USB-2 port on Bus 3 ) + plus one UBS-3 port.

I have two devices attached to my PC (aside from the Intel hubs, which we determined are actually built-in devices, even though logically they are attached to Bus 1 and Bus 2), namely the Prolific Technology, Inc. PL2303 Serial Port, which is a USB-to-RS232 converter/emulator and the Toshiba external USB drive. The Prolific RS dongle, even though attached to a USB-2 port, is itself a USB-1 device so it will not benefit from the USB-2 maximum transfer provided by the port. But then, again, it emulates a serial RS-232 port which can not use such high speeds anyway. The Toshiba USB 2.0 HD is attached to a USB 2.0 port (via one of the hubs’ connections) so we have a perfect match there – even if I attached it to the USB 3.0 port it would not benefit from the higher speed provided by it.

= = =
Another approach to determining the number of USB ports/devices and their speed is to browse the USB-related sysfs file structure:

$ls -1d /sys/bus/usb/devices/usb*
/sys/bus/usb/devices/usb1
/sys/bus/usb/devices/usb2
/sys/bus/usb/devices/usb3
/sys/bus/usb/devices/usb4

Here we see the sysfs representation of the Bus 001 … Bus 004 devices listed in lsusb. Browse these directories, particularly you may want to ‘cat’ the files ‘speed’ and ‘version’.

You may also use the usb-devices bash script, which presents the sysfs information in a more organized manner.

🙂

One thought on “How to check speed of USB port and/or external device on Linux

  1. Hey, thanks for this. I was looking for a quick and easy way to get the info about an installed PCIe card and this showed me exactly what I needed. Thanks

Leave a Reply

Your email address will not be published. Required fields are marked *