In the world of USB computer peripherals, almost everyone uses some sort of USB devices in their computer. These days there are USB webcams, USB hard drives, USB stick also known as PenDrive etc. Almost every device has a USB version of it. So if you’re using Linux, listing what USB device is connected to your system might be necessary at some point.
There are many programs and many ways to list USB devices on Linux.
In this article, I will show you how to list USB devices on Linux. I am using Ubuntu 18.04 Bionic Beaver for the demonstration, but these commands are available on every Linux distribution. So let’s get started.
Listing USB Devices using lsusb Command
The widely used lsusb command can be used to list all the connected USB devices in Linux.
As you can see from the output of the lsusb command in the screenshot below, all the connected USB device is listed. The Bus ID, Device ID, USB ID, and a title is displayed in the output of lsusb command.
As you can see in the marked section of the screenshot below, Realtek Semiconductor Corp. with ID 0bda:57cb, this is my USB Webcam.
You can’t tell that it’s a Webcam by looking at the output of lsusb command, Can you? Nope! So how do I know this? It’s because I checked the output of the lsusb command before and after connecting the USB Webcam and once I compared the outputs, the newly added row is the USB device I connected. Plain! But there are ways to find out what the USB device is.
You can use the dmesg command to find out more information about the connected USB devices. The last connected USB device is the easiest to find with dmesg command. It is more widely used for debugging purpose. You will shortly see why.
You run dmesg command as follows:
As you can see in the yellow marked box in the screenshot below, these are information about the USB device I connected last, which was my USB Webcam. You can see in one of the blue marked box, the USB device I connected is a HD UVC WebCam and its ID is 0bda:57cb.
By now you may have found out that the output of dmesg command is system log messages. Well yes, it is.
You can also search for a specific USB device by its ID in the dmesg system log.
Run the following command to open the output of dmesg command with less text pager:
You should see the following window:
Now to search for a string, press / key on your keyboard. And you should the a / appear on the bottom of terminal window as marked in the screenshot below.
Now type in the USB device ID. For example, earlier when I listed the connected USB devices with lsusb command, one of the USB device had ID 0bda:57cb
Type in the USB Device ID and press <Enter>. As you can see in the marked section of the screenshot below, the search string is marked white.
You may press <Up> and <Down> arrow keys to navigate up and down and read through it. You should find a lot of information about that USB device as you can see in the marked section of the screenshot below.
Listing USB devices with usb-devices Command
You can run the following command to list all the connected USB devices of your system:
As you can see in the screenshot below, all the connected USB devices are listed. we can find out pretty much the same information as before with usb-devices command.
Listing Block USB Devices
If you want to list all the USB block storage devices, that is all the USB storage devices, then you can use the lsblk or fdisk command to do so.
Listing USB block storage devices with lsblk:
As you can see in the screenshot below, all the available block storage devices (including the USB block storage devices) are listed.
You can get almost the same information as lsblk command with blkid command. But you have to run it as root as follows:
You can also use fdisk command to list all the USB block storage devices as follows:
As you can see in the screenshot below, the connected block storage devices (including the USB devices) are listed.
That’s how you list all the USB devices on Linux. Thanks for reading this article.