How to discover in wich USB port your device is plugged?

Solution Verified - Updated -

Environment

  • Red Hat Enterprise Linux 5 all releases

Issue

  • Do you need to know in which port your device is connected to.
  • This information is really important, for example, when you have a equipament like a nobreak APC connected via USB and the nobreak software requires that you inform what is the device name used (/dev/xx).

Resolution

  • Use lsusb command to check in which bus and device the equipament is connected to:

    # lsusb
    
    Bus 006 Device 001: ID 0000:0000 
    Bus 006 Device 002: ID 03f0:1027 Hewlett-Packard 
    Bus 005 Device 001: ID 0000:0000 
    Bus 005 Device 002: ID 051d:0002 American Power Conversion Uninterruptible Power Supply 
    Bus 003 Device 001: ID 0000:0000 
    Bus 004 Device 001: ID 0000:0000 
    Bus 002 Device 001: ID 0000:0000 
    Bus 001 Device 001: ID 0000:0000
    
  • Note that nobreak is connected to Bus 005 and Device 002 in this example:

    Bus 005 Device 002: ID 051d:0002 American Power Conversion Uninterruptible Power Supply
    
  • Find out which /dev corresponds to Bus 005 and Device 002 going to /dev/bus/usb:

    # ls -l /dev/bus/usb/005/002
    crw-r--r-- 1 root root 189, 1 Jul 14 09:27 /dev/bus/usb/005/002
    
  • Where:

     005 directory refrers to the Bus and 002 refrers to the Device you saw in lsusb output.
  • When nobreak software ask you to inform the device where to equipament is connected to, inform /dev/bus/usb/005/002.

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments