Check usb device in linux

How to detect an USB device?

I got a scenario, where a software works only when you insert the USB device provided by the software vendor in windows operating system. Im trying to find the content stored in the USB device. In windows operating system, the USB device icon is not shown in My_Computer. I thought, I can see the content or atleast detect the USB device in Ubuntu. Also in ubuntu, the drive is not detected. I tried «sudo fdisk -l» to know the file system, but its not useful. The drive is not detected at all. I wanted to know, how the software works only when the USB drive is inserted and it wont when it is not inserted. Do they have any files stored in the USB device? In any case, how can we detect such kind of device in Ubuntu?

5 Answers 5

To detect your USB device, in a terminal, you can try:

$ lsusb Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 001 Device 002: ID 046d:0809 Logitech, Inc. Webcam Pro 9000 Bus 003 Device 002: ID 046d:c016 Logitech, Inc. Optical Wheel Mouse 
sudo apt-get install input-utils lsinput 
$ lsinput /dev/input/event0 . /dev/input/event1 . /dev/input/event2 . /dev/input/event3 bustype : BUS_USB vendor : 0x46d product : 0xc016 version : 272 name : "Logitech Optical USB Mouse" phys : "usb-0000:00:1d.1-2/input0" uniq : "" bits ev : EV_SYN EV_KEY EV_REL EV_MSC 
$ udevadm monitor --udev monitor will print the received events for: UDEV - the event which udev sends out after rule processing UDEV [1915.787445] add /devices/pci0000:00/0000:00:1d.3/usb5/5-2 (usb) UDEV [1915.796226] add /devices/pci0000:00/0000:00:1d.3/usb5/5-2/5-2:1.0 (usb) 

But it might not work. In my case I m trying to make my Leapfrog Tag run on Ubuntu without success.

Thanks for your input. «lsusb» and «udevadm» command list my device though «lsinput» command doesnt provide me any additional information.

If the device in question is a software protection dongle, it may not be a mass storage device.

A likely alternate device for it to implement would be an ethernet controller ; the software can communicate with the device via the network adapter, which won’t appear as a drive. Or the device could implement a serial port, or another device for which the drivers are included with the operating system.

In any case, this is not an appropriate forum to ask about circumventing the copy protection on Windows software, even if you are trying to do it using Ubuntu.

Читайте также:  Can veeam backup linux

If it’s a device who’s sole purpose is to prevent the software running without it being present, it’s a software protection dongle.

Thanks a lot for your comment. It was valuable input for me. I have identified that it is a software protection dongle with your help. I wanted to know much about the technology being used in it and other technical stuff. Do you know any forum like «askubuntu» sort?. I also googled to find about the same. But im not convinced.

What also works nice when your PC hardware has difficulties with usb events is running a cronjob.

This forces a complete scan of the connected USB devices.
Each minute the situation is updated.

Does anyone know if this actually scans the USB ports or does it simply scan the /dev/usb/ directory for already known devices. The way the manpage describes it, appears to only scan the device directory and doesn’t refresh the ports.

If you want to detect how a USB device is being loaded- with excellent granularity- here are (2) ways:

udevadm monitor : This will show you the USB device being loaded as the USB Bus sees it.

udevadm is part of the default package udev on 18.04 LTS; no need to install it.

Execute udevadm monitor BEFORE you insert the USB device however.

Specimen output loading a USB flash drive shown below. Skip to the last line and you can even see what device it loaded as (sda1):

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) 

dmesg (which prints the Kernel ring buffer) will also give you granular visibility into the loading of your USB device.

However, dmesg in contrast to udevadm monitor shows you how loading of your external USB device from the Kernel’s perspective

Specimen output from dmesg -this time from a USB external CD drive- shown below. The «1-2» refers to its’ location on the USB bus: First bus, second port. Had I connected the CD drive to the other port, it would have reported «1-1«:

[ 55.296482] usb 1-2: new high-speed USB device number 4 using xhci_hcd [ 55.453715] usb 1-2: New USB device found, idVendor=1c6b, idProduct=a222 [ 55.453730] usb 1-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3 [ 55.453740] usb 1-2: Product: Mass Storage Device [ 55.453749] usb 1-2: Manufacturer: USB2.0 External [ 55.453758] usb 1-2: SerialNumber: 2010100500000000174 [ 55.525860] usb-storage 1-2:1.0: USB Mass Storage device detected [ 55.527273] scsi host0: usb-storage 1-2:1.0 [ 55.530031] usbcore: registered new interface driver usb-storage [ 55.545215] usbcore: registered new interface driver uas [ 56.553073] scsi 0:0:0:0: CD-ROM slimtype eTDU108 1 SL46 PQ: 0 ANSI: 0 

Источник

Читайте также:  Adobe acrobat reader on linux

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.

list usb with lsusb command linux

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).

Nautilus showing connected USB devices

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.

Use GNOME Disks to list mounted USB devices

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.

Читайте также:  Linux анализ занятого места

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.

Use df command to list mounted USB drives

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.

Using lsblk to list connected USb devicesUsing blkid to list connected USb devices

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 blkid to list connected USb devices

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.

Use fidsk to list usb devices

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.

Источник

Оцените статью
Adblock
detector