Created
September 4, 2019 12:10
-
-
Save Snawoot/b754872ce914859ab835bb7b12d1e9e2 to your computer and use it in GitHub Desktop.
Shell script to restart USB wifi adapter on Linux
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
for device in $(ls /sys/bus/usb/devices/*/product) ; do | |
dir="$(dirname "$device")" | |
if [ "$(cat "$device")" = "802.11n NIC" ] ; then | |
port="$(basename "$dir")" | |
echo Restarting "$port"... | |
echo "$port" > /sys/bus/usb/drivers/usb/unbind | |
sleep 2 | |
echo "$port" > /sys/bus/usb/drivers/usb/bind | |
echo "Port $port restarted." | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment