Ubuntu – How to unbind/bind a usb device as normal user

usb

I have an unstable usb-device that needs to be reset every five minutes. So far, I manually unplugged it which is rather annoying. I found out that it's possible to reactivate it by unbinding/rebinding, so that it can be rescued by this script: (I can parse the path from lsusb -t)

echo '1-1' > /sys/bus/usb/drivers/usb/unbind
echo '1-1' > /sys/bus/usb/drivers/usb/bind


This script can onlty be executed by root, but I'd like to integrate the calls into my application (C++ binary). Running everything as su sounds like an overkill and I hope that there is something like a group that has this ability.

To give the user "foo" root privileges via the sudo command, edit /etc/sudoers and add the line:

foo   ALL = NOPASSWD: ALL


echo -n devicePath > /sys/bus/usb/drivers/usb/unbind