Where is my keyboard, mouse and other HCI devices mounted in linux?

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)

2 Answers

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/"* ]] && exit eval "$(udevadm info -q property --export -p $syspath)" [[ -z "$ID_SERIAL" ]] && exit echo "/dev/$devname - $ID_SERIAL" )
done
2

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 )

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like