I'm using two devices which are an USB to Serial converter and a GSM module. Both of them are shown as /dev/ttyUSB(0 and 1).

How can I determine which file descriptor (FD) is which USB device?


You could set up some udev rules. There is some information here.

That way you can make sure your serial converter and GSM modules consistently mount to the same place.

| improve this answer | |
  • 1
    well after GG the udev rules, I can map the device to an permanent FD. Thanks – Nam Phung Apr 19 '16 at 10:08

As hinted, you may find information using lsusb. However — assuming you don't know how plug and play works on USB — the "why" lsusb is that every removable device, that you plug into the USB connector, signals to the system (amongst other information) identifiers for the vendor and product, respectively idVendor and idProduct, both of which you can see in lsusb output.

Another way is to check the system log, which provides more verbose information:

Apr 19 11:20:05 my_machine kernel: [1768201.806503] usb 3-3: new full-speed USB device number 72 using xhci_hcd
Apr 19 11:20:05 my_machine kernel: [1768201.823169] usb 3-3: New USB device found, idVendor=067b, idProduct=2303
Apr 19 11:20:05 my_machine kernel: [1768201.823179] usb 3-3: New USB device strings: Mfr=1, Product=2, SerialNumber=0
Apr 19 11:20:05 my_machine kernel: [1768201.823185] usb 3-3: Product: USB-Serial Controller D
Apr 19 11:20:05 my_machine kernel: [1768201.823191] usb 3-3: Manufacturer: Prolific Technology Inc. 
Apr 19 11:20:05 my_machine kernel: [1768201.824118] pl2303 3-3:1.0: pl2303 converter detected
Apr 19 11:20:05 my_machine kernel: [1768201.825628] usb 3-3: pl2303 converter now attached to ttyUSB0
Apr 19 11:20:05 my_machine mtp-probe: checking bus 3, device 72: "/sys/devices/pci0000:00/0000:00:14.0/usb3/3-3"

In this log excerpt you will see the VendorID and ProductID of a Serial-on-USB controller, which uses a chip, a PL2303 (pl2303), from a company named "Prolific Technology Inc.".

By looking at these lines you will know what device you plugged in (e.g. idVendor=067b, idProduct=2303), when (Apr 19 11:20:05) and what device node the device (ttyUSB0) can be accessed through. You'll also get the full system path to the device, namely /sys/devices/pci0000:00/0000:00:14.0/usb3/3-3.

On a Debian machine, or on a Raspberry Pi installed with Raspbian, the system log file is /var/log/syslog.

| improve this answer | |

Use lsusb. This should give you the data that you require and enable you to determine which FD points to which device.

lsusb is a utility for displaying information about USB buses in the system and the devices connected to them.

See man page or type man lsusb in a terminal.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.