4

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?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Manku
  • 431
  • 3
  • 9
  • 16
  • I tried dmesg | tail, It is showing only USB details like VID,PID,product name, manufacturer name etc. I can't know ?, where udev (device manager) is attaching device under /dev/ – Manku Jul 04 '14 at 13:13

2 Answers2

8

It isn't 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.

Sun
  • 1,505
  • 17
  • 25
4

Here is an example of lsusb output on my laptop:

Bus 004 Device 123: ID 2001:3c1b D-Link Corp. DWA-127 Wireless N 150 High-Gain Adapter(rev.A1) [Ralink RT3070]

It's the device 123 on the bus 004. /dev/bus/usb/004/123 is just the file for the interested device.

The path might vary on different kernels. The result above holds on kernel 3.15.2

Chih-Hsuan Yen
  • 754
  • 2
  • 11
  • 29
  • Yes, i saw. But it is showing only USB character device type following by /dev/bus/usb/004/123 (example case).Suppose if i take example of USB mass storage, then it should be shown as block device to perform operations.how can i know block device path like /dev/sdb (example case). – Manku Jul 04 '14 at 13:21
  • 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/. – Sun Jul 05 '14 at 03:58