- How to List USB Devices Connected to Your Linux System
- Check connected USB devices graphically
- Using the mount command to list the mounted USB devices
- Using df command
- Using lsblk command
- Using fdisk
- Inspecting /proc/mounts
- Display all the USB devices with lsusb command
- Conclusion
- Ubuntu/Debian How to identify USB port of device
- How to List USB Devices in Linux
- List USB Device Names Using df Command
- List USB Device Name using lsblk Command
- List USB Device Names Using fdisk Command
- List USB Devices Details using lsusb Command
- List USB controllers and devices using usb-devices
- Conclusion
How to List USB Devices Connected to Your Linux System
Mostly, people are interested in knowing what USB devices are connected to the system. This may help troubleshoot the USB devices.
The most reliable way is to use this command:
It shows the webcam, Bluetooth, and Ethernet ports along with the USB ports and mounted USB drives.
But understanding the output of lsusb is not easy and you may not need to complicate things when you just want to see and access the mounted USB drives.
I will show you various tools and commands you can use to list USB devices connected to your system.
I have connected a 2GB pen-drive, 1TB external HDD, Android smartphone via MTP and USB mouse in the examples unless stated otherwise.
Let me start with the simplest of the options for desktop users.
Check connected USB devices graphically
Your distribution file manager can be used to view USB storage devices connected to your computer. As you can see in the screenshot of Nautilus (GNOME File Manager) below.
The connected devices are shown in the sidebar (Only USB Storage devices are shown here).
You can also use GUI applications like GNOME Disks or Gparted to view, format, and partition the USB Storage devices connected to your computer. GNOME Disks is preinstalled in most distributions using GNOME Desktop Environment by default.
This app also works as a very good partition manager too.
Enough of the Graphical tools. Let us discuss the commands you can use for listing the USB devices.
Using the mount command to list the mounted USB devices
The mount command is used for mounting partitions in Linux. You can also list USB storage devices using the same command.
Generally, USB storage is mounted in the media directory. Thus, filtering the output of mount command on media will give you the desired result.
Using df command
df command is a standard UNIX command used to know the amount of available disk space. You can also use this command to list USB storage devices connected using the command below.
Using lsblk command
The lsblk command is used to list block devices in the terminal. So, here also by filtering the output containing media keyword, you can get the desired result as shown in the screenshot below.
If you are more curious, you can use the blkid command to know the UUID, Label, Block size etc.
This command gives more output as your internal drives are also listed. So, you have to take references from the above command to identify the device you wish to know about.
Using fdisk
fdisk, the good old command line partition manager, can also list the USB storage devices connected to your computer. The output of this command is also very long. So, usually, the connected devices get listed at the bottom as shown below.
Inspecting /proc/mounts
By inspecting the /proc/mounts file, you can list the USB Storage devices. As you can notice, it shows you the mount options being used by filesystem along with the mount point.
cat /proc/mounts | grep media
Display all the USB devices with lsusb command
And we revisit the famed lsusb command.
Linux kernel developer Greg Kroah-Hartman developed this handy usbutils utility. This provides us with two commands i.e. lsusb and usb-devices to list USB devices in Linux.
The lsusb command lists all the information about the USB bus in the system.
As you can see this command also shows the Mouse and Smartphone I have connected, unlike other commands (which are capable of listing only USB storage devices).
The second command usb-devices gives more details as compared but fails to list all devices, as shown below.
Greg has also developed a small GTK application called Usbview. This application shows you the list of all the USB devices connected to your computer.
The application is available in the official repositories of most Linux distributions. You can install usbview package using your distribution’s package manager easily.
Once installed, you can launch it from the application menu. You can select any of the listed devices to get details, as shown in the screenshot below.
Conclusion
Most of the methods listed are limited to USB storage devices. There are only two methods which can list other peripherals also; usbview and usbutils. I guess we have one more reason to be grateful to the Linux Kernel developer Greg for developing these handy tools.
I am aware that there are many more ways to list USB devices connected to your system. Your suggestions are welcome.
Ubuntu/Debian How to identify USB port of device
How can you identify individual USB devices to unbind and bind them? Specifically, devices like mice, keyboard, dongles, etc. which are not storage. For example, on Debian (Raspbian GNU/Linux v8.0 in this case), I have a few devices listed in /sys/bus/usb/drivers/usbhid/: ls /sys/bus/usb/drivers/usbhid/ shows USB devices:
1-1.2:1.0 1-1.2:1.1 1-1.2:1.2 1-1.3:1.0 1-1.3:1.1 1-1.4:2.2
Bus 001 Device 006: ID 1410:9020 Novatel Wireless Bus 001 Device 009: ID 045e:00db Microsoft Corp. Natural Ergonomic Keyboard 4000 V1.0 Bus 001 Device 008: ID 046d:c52b Logitech, Inc. Unifying Receiver Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp. Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
/: Bus 01.Port 1: Dev 1, Driver=dwc_otg/1p, 480M |__ Port 1: Dev 2, If 0, Driver=hub/5p, 480M |__ Port 1: Dev 3, If 0, Specific Class, Driver=smsc95xx, 480M |__ Port 2: Dev 8, If 0, Interface Device, Driver=usbhid, 12M |__ Port 2: Dev 8, If 1, Interface Device, Driver=usbhid, 12M |__ Port 2: Dev 8, If 2, Interface Device, Driver=usbhid, 12M |__ Port 3: Dev 9, If 0, Interface Device, Driver=usbhid, 1.5M |__ Port 3: Dev 9, If 1, Interface Device, Driver=usbhid, 1.5M |__ Port 4: Dev 6, If 0, Driver=cdc_ether, 480M |__ Port 4: Dev 6, If 1, Data, Driver=cdc_ether, 480M |__ Port 4: Dev 6, If 2, Interface Device, Driver=usbhid, 480M
I know that the Novatel Wireless is 1-1.4:2.2 from guessing. I can then reset it by running echo -n ‘1-1.4:2.2’ > /sys/bus/usb/drivers/usbhid/unbind and echo -n ‘1-1.4:2.2’ > /sys/bus/usb/drivers/usbhid/bind It would be great if there was an obvious way to identify it and reset it in a bash script. Also, how can a device be identified and reset if there are more than one of the same hardware on different ports?
How to List USB Devices in Linux
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 the 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.
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.
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.
To retrieve additional information such as the UUID, manufacturer and filesystem type, use the blkid command as shown.
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.
The command will display detailed information about your USB volume including the partitions, size of the volume, sectors, and the filesystem type.
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.
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.
Also, you can pipe the output of dmesg command to less for easier scrolling.
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.
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:
Conclusion
In this guide, we have demonstrated different ways to list the USB devices attached to the Linux system.
Which is your favorite command to list USB? Please provide your suggestions and feedback in the comment section.
If this resource helped you, let us know your care by a Thanks Tweet. Tweet a thanks