How to List USB Devices in Linux

Written by: James Kiarie   |   Last updated: October 10, 2023

Nowadays, many computer peripherals such as webcams, mice, scanners, printers, hard drives, USB (Pendrive) now come as USB devices. Once these devices are connected to the Desktop or server it's important to know the device name or device path. This helps to identify USB devices for tasks such as formatting.

In Linux, all device files are stored in /dev directory and must be available to the OS during the system boot.

In this guide, we will show you the various ways to list USB devices on Linux. Most commands mentioned here should work on all Linux distributions.

Commands to List USB Devices

Let's look into the Linux commands to list USB Devices:

1. lsusb : Lists all USB buses and connected USB devices.

2. usb-devices : Script to show all USB devices with a lot of detail.

3. df -Th | grep media : Identify automatically mounted USB.

4. lsblk : Lists information about all available or specified block devices.

5. fdisk -l : List all block devices, which will naturally include USB devices.

6. dmesg | grep usb : Check for USB device connections and issues.

7. usbview : A GUI tool that shows the tree of USB devices in your system.

List USB Device Names Using df Command

The df command is a useful command that can help list all mounted volumes, including your USB drives.

Once a USB device is plugged into a Linux system, especially for Desktop, it is automatically mounted in the /media partition and becomes ready for use.

df -Th | grep media
df command check plugged in USB devices
df command check plugged in USB devices

From the output above, I have 1 USB drive /dev/sdb with 2 partitions /dev/sdb1 and /dev/sdb2

List USB Device Name using lsblk Command

Lsblk command is used to list all block devices on a Linux system. From the list, you can filter USB devices using the grep command.

For example:

lsblk | grep sd
lsblk command check plugged in USB devices
lsblk command list USB devices

To retrieve additional information such as the UUID, manufacturer and filesystem type, use the blkid command as shown.

sudo blkid
blkid command output retrieve information on USB block devices
blkid command output retrieve information on USB block devices

List USB Device Names Using fdisk Command

You can use the good old fdisk command that is used for partitioning volumes to list all the partitions on the Linux system, including the USB drives.

sudo fdisk -l

The command will display detailed information about your USB volume including the partitions, size of the volume, sectors, and the filesystem type.

fdisk command list USB devices
fdisk command

List USB Devices Details using lsusb Command

The lsusb command, also known as the “List USB” command, is used in Linux to list all the USB devices attached to the system.

lsusb
lsusb command
lsusb command

The output above displays the Bus ID, Device ID, USB ID, and the vendor or manufacturer of the USB devices

The lsusb command simply lists the connected devices and does not provide further information about the usb devices.  

For more information about the attached USB devices use the dmesg command. The dmesg command also known as “driver message” or “display the message” is used for examining the boot messages. Additionally, it is used for debugging hardware-related issues and printing messages generated by device drivers.

You can use the dmesg command and grep to narrow down to USB devices.

dmesg | grep usb
dmesg command
dmesg command

Also, you can pipe the output of dmesg command to less for easier scrolling.

dmesg | less

On the output, you can search for a specific string by pressing the forward slash key ( / ) on your keyboard followed by the name or Device ID of the USB device.

In my case, I'm searching for more information regarding a USB device called SanDisk, which is actually my removable pen drive.

Search for a USB drive
Search for a USB drive

List USB controllers and devices using usb-devices

The usb-devices command is a shell script that allows you to list all the USB controllers and the USB devices connected to your PC. It prints out details of the USB device such as the manufacturer, product name, serial number, and so much more. Here's the output of the command:

usb-devices
usb-devices command to list usb devices
usb-devices command to list usb devices

About The Author

James Kiarie

James Kiarie

James Kiarie is a skilled and certified LPIC Linux administrator with a strong passion for technical writing, specializing in the Linux domain. With over four years of experience, he has crafted numerous technical guides, helping a wide audience navigate through various Linux distributions.

SHARE

Comments

Please add comments below to provide the author your ideas, appreciation and feedback.

Leave a Reply

Leave a Comment