6

i have heard that everything in linux is treated as files.. i was just curious as to where would i find to explore the usb mounted on my machine (HCI dev)

8

You can get a list of USB devices connected to your machine via the command:

lsusb

You can monitor input events from USB and other devices via:

evtest

which will also tell you the device path (e.g. mouse and keyboard, as well as power button, etc.) in /dev/input/event*. You might need to install the evtest package for that.

This is a script (taken from this answer on Unix SE) which searches /sys looking for USB devices (i.e. the ones with a ID_SERIAL attribute):

#!/bin/bash

for sysdevpath in $(find /sys/bus/usb/devices/usb*/ -name dev); do
    (
        syspath="${sysdevpath%/dev}"
        devname="$(udevadm info -q name -p $syspath)"
        [[ "$devname" == "bus/"* ]] && continue
        eval "$(udevadm info -q property --export -p $syspath)"
        [[ -z "$ID_SERIAL" ]] && continue
        echo "/dev/$devname - $ID_SERIAL"
    )
done
| improve this answer | |
  • i ran the evtest commmand... i chose for the touchpad event... i saw that the output also gives me value of pressure i apply on touchpad... can u pls share the code ,running which i get a pop up (sort of toast ) if i press the touch pad hard – juggernauthk108 Jan 24 '16 at 17:46
  • moreover when i cd /dev/input/ i see something called as "mice" "mouse1" "mouse0" and "mouse2" other than the directory by-id and by-path and the 13 events that evtest command would anyways display... how can make use of these "mice" "mouse1" "mouse0" and "mouse2"? – juggernauthk108 Jan 24 '16 at 17:50
1

I assume that you connect usb devices. When you type:

lsusb  

you have list connected usb devices. You can read bus and device number. Then when you type:

lsusb -t   

( bus and device number are known from lsusb ) you can read port number of device you are checking. e.g my mouse is on bus 001, device 004 and this belongs to port 14.

Now when you go to:

/sys/bus/usb/drivers/usb   

you can see there is e.g symlink 1-14 which is responsible for my mouse (bus 1, port 14). You can use realpath 1-14 command to see where this symlink leads
(You can disable this port by typing: echo '1-14' | sudo tee unbind )

| 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.