USB device detection on /dev directory on Linux

Manku picture Manku · Jul 4, 2014 · Viewed 12.2k times · Source

Using the lsusb command in Linux I have come to know about bus and device numbers, along with its name of newly attached USB devices.

But how can I know on which device directory (/dev/*) USB device get attached in Linux using command lines only?

Answer

Sundeep471 picture Sundeep471 · Jul 5, 2014

It's not a rule that every device has to show up directly under /dev/, but some device classes will be nested under sub-directories inside /dev/

USB device drivers are a bit different, If you connect a valid USB device, USB HCI would read the VID:PID and will tell the usb-core that the device with VID:PID combination is connected.

If the usbcore detects any registered driver for the VID:PID combination, it will couple it with the device, and the device file creation would happen accordingly

The device will show in /dev/bus/usb/.., even if, the corresponding driver is not present, to indicate that the device was detected.

You need to have the device driver to have the device in action/operation.

You can verify whether a device driver is coupled to the device through

cat /sys/kernel/debug/usb/devices

Each detected USB device will have an entry here, and also shows the "Driver=" field, to show which driver is associated with your device.

Now, IFF there is a driver, that makes an entry in appropriate /dev tree, you will find the device there.

NOT every device will show up directly under /dev/ in the first level. say, your mouse/keyboard will not show-up directly under /dev, but inside /dev/input/

Likewise, IF the connected USB device is a char/block device, it MAY show up there, that too have exceptions.

If your device is and ethernet/wifi device, the interface device will NOT show up under /dev/, cross-check with your existing eth0, wlan0, they will not appear directly under /dev/, but will in /proc/net/devices

sda/b/c shows up under /dev directly, because they are block devices and are managed by udev, as such.