How to List USB Devices in Linux?

These days, there are a lot of devices that come with USB ports. These so-called USB devices are connected to the desktop operating system. These devices include printers, webcams, USBs (flash drives), etc., in Linux. It is important to know the name of the connected USB devices to perform various tasks, such as formatting the USB. There are various ways to list down the name of the connected USB devices that Linux provides.

This article will demonstrate the various methods to list down USB devices in Linux. The content for the post is:

Method 1: List USB Devices Through lsusb Utility

The first method to list down the USB devices is using the “lsusb” command. The lsusb is the utility for displaying the information of the USB buses along with the device ID and names. To list the USB devices, first check the output of the lsusb command without connecting any USB device:

$ lsusb

All the USB devices will be listed.

Let’s connect the USB to the computer and list it using the lsusb utility:

Our connected USB device has been listed as shown in the above image.

Method 2: List USB Devices Through dmesg Utility

The second way to list the USB devices is using the “dmesg” command. The “dmesg” is the utility for printing Kernel-related messages. As we all know, every task performed in the operating system loads in the Kernel. So, we can use this command to display the Kernel message related to the USB devices and get the connected USB’s name. To do so, run the “dmesg” command with sudo permission and scroll down to find the USB Services:

$ dmesg

In the above image, the highlighted area shows the name of the connected USB device.

You can also search the USB device by its specific ID that can be obtained using the “lsusb” command as described in method 1. To do so, use the “less” command with the “dmesg” command, press the forwards to slash “/” from the keyboard, and type the ID of the USB device:

$ sudo dmesg | less

After typing the USB device ID hit the enter button:

The USB device with its particular ID (connected USB) is displayed.

Note: If you want to know more about the dmesg command, check out our latest article on the dmesg command.

Method 3: List USB Devices Through usb-devices Utility

Another method to list the USB devices is simply using the “usb-devices” command. This command will display the connected USB devices in the operating system. Check the execution of the below command:

$ usb-devices

The connected USB device has been listed.

Method 4: List USB Devices Through lsblk Utility

Using the “lsblk” command, the user can also display the USB devices. However, the “lsblk” command is used to display the block devices, but this can be filtered out using the “grep” command. Run the given command in the terminal:

$ lsblk | grep sd

The connected USB device has been listed.

Method 5: List USB Devices Through df Utility

The “df” command is the utility to display the mounted devices that will also display the connected USB devices with the computer. Every device is mounted in the media directory automatically, so we can use the “grep” command to display the mounted devices. Let’s check and run it in the terminal:

$ df -Th | grep media

The connected USB device has been displayed with the name “/dev/sdb1”.

Method 6: List USB Devices Through fdisk Utility

The fdisk (fixed disk) is utilized for formatting the USB drives. This command will display the detailed USB device information. To run it, use it with the “l” option for displaying the list of the USB devices:

$ sudo fdisk -l

The above image shows that the connected USB device has been displayed.

Conclusion

In Linux, to list down the USB devices, there are 5 methods. The first method uses the “lsusb” utility, which lists all the connected USB devices. The second method is to use the dmesg command to display the Kernel message of the connected USB device. The third method is to use the “usb-devices” utility, while the fourth, fifth, and sixth methods use the “lsblk”, “df” or “fdisk” utility in the terminal. This write-up has illustrated the most frequently used methods for listing USB devices in Linux.