Skip to content

Instantly share code, notes, and snippets.

@elfmimi
Last active December 18, 2022 07:34
Show Gist options
  • Save elfmimi/0be2c81b95e0ef90698ca0e22a1bc433 to your computer and use it in GitHub Desktop.
Save elfmimi/0be2c81b95e0ef90698ca0e22a1bc433 to your computer and use it in GitHub Desktop.
Reset Linux USB subsystem without rebooting
#!/bin/bash
# root privilege required
if cd /sys/bus/platform/drivers/ehci-platform >& /dev/null; then
for dev in *.usb; do
echo -n $dev > unbind
echo -n $dev > bind
done
fi
if cd /sys/bus/platform/drivers/ohci-platform >& /dev/null; then
for dev in *.usb; do
echo -n $dev > unbind
echo -n $dev > bind
done
fi
#!/bin/bash
# root privilege required
if cd /sys/bus/pci/drivers/ehci-pci >& /dev/null; then
for dev in 0000:*; do
echo -n $dev > unbind
echo -n $dev > bind
done
fi
if cd /sys/bus/pci/drivers/ehci_hcd >& /dev/null; then
for dev in 0000:*; do
echo -n $dev > unbind
echo -n $dev > bind
done
fi
if cd /sys/bus/pci/drivers/xhci_hcd >& /dev/null; then
for dev in 0000:*; do
echo -n $dev > unbind
echo -n $dev > bind
done
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment