After plugging the USB to the port of my machine, if I do lsusb I see the device I am looking for:

Bus 001 Device 004: ID 04f2:b573 Some Manufacturer

If I list the devices under /dev/, I can see lots of device paths, such as /dev/tty0, /dev/ttyUSB0... etc. For what I understand, one of these paths will be my USB device, or be where my USB device is connected to.

How do I know which one is the one with the ID 04f2:b573?

This question is similar to mine, however (referring to the accepted answer) I don't know what exactly is $ID_SERIAL, or how to I set it to be equal to the Id I'm looking for, or even what is the correct path (since his example shows multiple device paths, such as /dev/ttyACM0, /dev/sdb, /dev/input/event5 ...)

Also, the second answer assumes that I know the device is connected to /dev/ttyUSB0, which I don't know beforehand (testing it on this specific path gives me no device, by the way).

2 Answers 2


How do I know which one is the one with the ID 04f2:b573?

There may be better ways to do it, but a quick and dirty way to do it is with:

    v=${1%:*}; p=${1#*:}  # split vid:pid into 2 vars
    v=${v#${v%%[!0]*}}; p=${p#${p%%[!0]*}}  # strip leading zeros
    grep -il "^PRODUCT=$v/$p" /sys/bus/usb/devices/*:*/uevent |
    sed s,uevent,, |
    xargs -r grep -r '^DEVNAME=' --include uevent
find_by_id 04f2:b573

My old Huawei phone appears as two serial ttys:

$ find_by_id 12d1:

You can change the last grep to

xargs -r egrep -rB2 '^DEVNAME=|^IFINDEX=' --include uevent

in order to also find the usb network interfaces:

$ find_by_id 0e8d:

$ find_by_id 03f0:
  • I thought there would be an easier way but this worked, thanks!
    – Bersan
    Feb 12, 2020 at 16:05

The answer by @mosvy does not work on Debian systems because /sys/bus/usb/devices contains symlinks. It also will not work by following symlinks with grep -R because that filesystem contains symlink loops.

A simpler way to get what you need is:

lsusb | grep NameOfYourDevice | sed -nr 's|Bus (.*) Device ([^:]*):.*|/dev/bus/usb/\1/\2|p'

It converts the output of lsusb (from the usbutils package) to the /dev/bus/usb/... path

If you need a block/character device name, try something like this:

device() {
    v=${1%:*}; p=${1#*:}
    for dir in `find /sys/ -name idVendor | rev | cut -d/ -f 2- | rev`; do
        if grep -q $v $dir/idVendor; then
            if grep -q $p $dir/idProduct; then
                find $dir -name 'device' | rev | cut -d / -f 2 | rev

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.