Skip to content

Instantly share code, notes, and snippets.

@deckerego
Last active October 22, 2025 16:17
Show Gist options
  • Select an option

  • Save deckerego/1a8596dd504ef584dd3437ae72eb20f3 to your computer and use it in GitHub Desktop.

Select an option

Save deckerego/1a8596dd504ef584dd3437ae72eb20f3 to your computer and use it in GitHub Desktop.
Reset all USB NICs at the hardware level
#!/bin/bash
for device in /sys/bus/usb/devices/*; do
grep "NIC" "$device/product" &>/dev/null
if [ "$?" == 0 ]; then
echo -n "Resetting "
cat "$device/product"
sh -c "echo 0 > $device/authorized"
sh -c "echo 1 > $device/authorized"
echo "Device reset."
fi
done
@deckerego
Copy link
Author

A wireless interface may go so incredibly sideways that it needs to be "ejected" and "re-added" - here's a way to do this in a script.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment