How can i get my USB wifi to work after a reboot?

You can activate the wlan by these commands instead of repluging:

sudo modprobe -r 8192eu
sudo modprobe 8192eu

You need change 8192eu to your own wlan name. If you don't know the name, search on google with keyword ID 148f:2070(your usb wlan's id which can be found by command lsusb).

Or you can just add the wlan name to /etc/modules:

sudo -i
echo 8192eu >> /etc/modules
exit

Then the wlan will be activated automatically when system start.


First you need to identify the driver for your USB wifi adapter. Execute the following command to get the list of network adapters lshw -C network Following is the kind of output you might notice

  *-network:0
       description: Wireless interface
       physical id: 1
       bus info: usb@3:5
       logical name: wlx542aa25b496d
       serial: 54:2a:a2:5b:49:6d
       capabilities: ethernet physical wireless
       configuration: broadcast=yes driver=rtl8xxxu driverversion=5.0.0-32-generic firmware=N/A ip=172.16.61.0 link=yes multicast=yes wireless=IEEE 802.11

Check the driver and note it down. Assume it is rtl8xxxu and you can use following commands to unplug or plug the adapter via commands

sudo modprobe -r rtl8xxxu
sudo modprobe rtl8xxxu

Since this again is manual invocation, you can add the commands in /etc/rc.local Add the following code just before exit 0

modprobe -r rtl8xxxu
sleep 1
modprobe rtl8xxxu

Int Ubuntu 18.04 the rc.local file doesn't exists, so you can create with sudo nano /etc/rc.local Add the following part which is taken from Ubuntu 16.04's stock /etc/rc.local file to automate it on system boot

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

exit 0

Then add the uplug/plug code before exit 0. You'll need to make the file executable by sudo chmod +x /etc/rc.local. Reboot and see if this works or not