Linux – How to reset an USB device without unplugging it in Linux


Every now and then there might come a need to reset a USB device, is there a way to perform the reset in software without unplugging the device itself and then pluggin it back in?

More specifically I have a webcam which gets confused when playing too much with the settings in guvcapture and then needs a reset to get back on track.

Best Answer

You could try Benjamin Close's resetusb program to reset all devices — there are no binaries available, but compiling it is rather easy. Save the source code as resetusb.c, then run:

gcc -lusb resetusb.c -o resetusb

You can now run the tool as resetusb. Alternatively, @unhammer points to Alan Stern's single-device version (plus some hints on how to use it).

Some people have also had luck just removing and modprobe-ing the relevant modules:

modprobe -vr ehci_hcd
modprobe -v ehci_hcd

(you could of course script this)

Some distributions may also have their own tools to restart the USB subsystem; Mandrake apparently has /etc/init.d/usb.