1

I want my computer to stop listening on a specific usb port. The problem is that the device connected there keeps disconnecting and reconnecting. I think this may be due to a hardware fault. The usb device is a touch screen. With the watch command I can verify that it keeps appearing and disappearing.

I've tried both blocking the kernel modules with modprobe and blocking the specific USB device with udev. Alas nothing seems to do the trick. What other options do I have?

For reference:

> cat /lib/udev/rules.d/20-block-elan.rules
# ELAN Touchscreen
SUBSYSTEM=="usb", ATTRS{idVendor}=="04f3", ATTRS{idProduct}=="0125", ATTR{authorized}="0"
1
  • i like how on this question there's a "closed because duplicate", linking to another thread that says in a comment "correct answer over there" linking to this thread, and neither answer actually achieves what was asked, because the power management works through the device driver, not the specific port...
    – nonchip
    Jul 24, 2021 at 9:20

1 Answer 1

3

You can disable specific usb ports. First see which devices are available:

for device in $(ls /sys/bus/usb/devices/*/product); do echo $device;cat $device;done

Which will give you a list of your connected devices for example:

/sys/bus/usb/devices/3-14/product
Logitech G430 Headset
/sys/bus/usb/devices/3-1/product
Razer DeathAdder Elite
/sys/bus/usb/devices/3-2/product
Keyboard G910
/sys/bus/usb/devices/4-3/product
USB 10/100/1000 LAN

If I would want to disable my mouse (Razer DeathAdder Elite from the List above) I would type:

echo suspend | sudo tee /sys/bus/usb/devices/3-1/power/level

And if I would want to turn it on again:

echo on | sudo tee /sys/bus/usb/devices/3-1/power/level
2
  • 1
    when I used the first tee command u mentioned, it threw me this error: :Invalid argument". As u can see the screenshot here: imgur.com/a/sNSksJo
    – Pranav
    May 27, 2021 at 12:06
  • 1
    Looks like the write error: Invalid argument is because this option is no longer supported, since kernel 2.6.32. See superuser.com/a/371254.
    – arjan
    Jun 3, 2022 at 14:12

Not the answer you're looking for? Browse other questions tagged .