- Getting information on my usb devices
- 3 Answers 3
- 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
Getting information on my usb devices
There used to be lots of info on usb devices, coming form /proc/bus/usb/devices. Then this was no longer auto mounted, so you had to mount it yourself (usbdevfs it was called, or something) Now, in 11.04, even that doesn’t work. How can I get some info on my device now?
3 Answers 3
Bus 003 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub Bus 002 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 001 Device 004: ID 0bda:0138 Realtek Semiconductor Corp. Bus 001 Device 003: ID 064e:c218 Suyin Corp. Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
What more do you need to know?
If you need more there is usbview on sourceforge: USBView is a GTK program that displays the topography of the devices that are plugged into the USB bus on a Linux machine. It also displays information on each of the devices. This can be useful to determine if a device is working properly or not.
did not try usbview in 11.04 btw
/proc is becoming deprecated, /sys/bus/usb/devices is what you are looking for. A program to query for USB devices is lsusb .
Here are a few nice tools for gathering USB info about connected devices,
This is part of the DEFAULT PACKAGE usbutils on 18.04 LTS. Specimen output:
T: Bus=01 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#= 1 Spd=480 MxCh= 6 D: Ver= 2.00 Cls=09(hub ) Sub=00 Prot=01 MxPS=64 #Cfgs= 1 P: Vendor=1d6b ProdID=0002 Rev=04.15 S: Manufacturer=Linux 4.15.0-1050-oem xhci-hcd S: Product=xHCI Host Controller S: SerialNumber=0000:00:14.0 C: #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=0mA I: If#= 0 Alt= 0 #EPs= 1 Cls=09(hub ) Sub=00 Prot=00 Driver=hub T: Bus=01 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#= 4 Spd=480 MxCh= 0 D: Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1 P: Vendor=0781 ProdID=5571 Rev=01.00 S: Manufacturer=SanDisk' S: Product=Cruzer Fit S: SerialNumber=4C530000280331109123 C: #Ifs= 1 Cfg#= 1 Atr=80 MxPwr=200mA I: If#= 0 Alt= 0 #EPs= 2 Cls=08(stor.) Sub=06 Prot=50 Driver=usb-storage
udevadm is part of the DEFAULT PACKAGE udev on 18.04 LTS.
Execute this command BEFORE you connect your USB device.
Note in the specimen output below it tells us which block device the USB flash drive loaded as:
udevadm monitor monitor will print the received events for: UDEV - the event which udev sends out after rule processing KERNEL - the kernel uevent KERNEL[969.010067] add /devices/pci0000:00/0000:00:14.0/usb1/1-1 (usb) KERNEL[969.010367] add /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0 (usb) KERNEL[969.018769] add /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0/host0 (scsi) KERNEL[969.018849] add /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0/host0/scsi_host/host0 (scsi_host) KERNEL[969.018934] bind /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0 (usb) KERNEL[969.019049] bind /devices/pci0000:00/0000:00:14.0/usb1/1-1 (usb) UDEV [969.024995] add /devices/pci0000:00/0000:00:14.0/usb1/1-1 (usb) UDEV [969.031390] add /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0 (usb) UDEV [969.036362] add /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0/host0 (scsi) UDEV [969.041258] add /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0/host0/scsi_host/host0 (scsi_host) UDEV [969.046202] bind /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0 (usb) UDEV [969.051734] bind /devices/pci0000:00/0000:00:14.0/usb1/1-1 (usb) KERNEL[970.051706] add /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0/host0/target0:0:0 (scsi) KERNEL[970.052068] add /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0/host0/target0:0:0/0:0:0:0 (scsi) KERNEL[970.052215] add /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0/host0/target0:0:0/0:0:0:0/scsi_disk/0:0:0:0 (scsi_disk) KERNEL[970.052435] bind /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0/host0/target0:0:0/0:0:0:0 (scsi) KERNEL[970.052585] add /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0/host0/target0:0:0/0:0:0:0/scsi_device/0:0:0:0 (scsi_device) KERNEL[970.052774] add /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0/host0/target0:0:0/0:0:0:0/scsi_generic/sg0 (scsi_generic) KERNEL[970.052963] add /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0/host0/target0:0:0/0:0:0:0/bsg/0:0:0:0 (bsg) UDEV [970.060833] add /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0/host0/target0:0:0 (scsi) KERNEL[970.061634] add /devices/virtual/bdi/8:0 (bdi) UDEV [970.069006] add /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0/host0/target0:0:0/0:0:0:0 (scsi) UDEV [970.071467] add /devices/virtual/bdi/8:0 (bdi) UDEV [970.075852] add /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0/host0/target0:0:0/0:0:0:0/scsi_disk/0:0:0:0 (scsi_disk) KERNEL[970.079839] add /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0/host0/target0:0:0/0:0:0:0/block/sda (block) KERNEL[970.079989] add /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0/host0/target0:0:0/0:0:0:0/block/sda/sda1 (block) UDEV [970.083556] bind /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0/host0/target0:0:0/0:0:0:0 (scsi) UDEV [970.091288] add /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0/host0/target0:0:0/0:0:0:0/scsi_device/0:0:0:0 (scsi_device) UDEV [970.091755] add /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0/host0/target0:0:0/0:0:0:0/scsi_generic/sg0 (scsi_generic) UDEV [970.106807] add /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0/host0/target0:0:0/0:0:0:0/bsg/0:0:0:0 (bsg) UDEV [970.339976] add /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0/host0/target0:0:0/0:0:0:0/block/sda (block) UDEV [970.519549] add /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0/host0/target0:0:0/0:0:0:0/block/sda/sda1 (block)
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.