sudo apt-get update && sudo apt-get upgrade
sudo apt-get install git build-essential dkms ssh curl bash linux-headers-$(uname -r) libelf-dev
lspci | grep -i "Wireless\|Wifi"
git clone -b extended https://github.com/lwfinger/rtlwifi_new.git
 
sudo dkms add ./rtlwifi_new
sudo dkms install rtlwifi-new/0.6
cd rtlwifi_new/
make
sudo make install
sudo modprobe -r rtl8192ee && sudo modprobe rtl8192ee
sudo modprobe -r rtl8192cu && sudo modprobe rtl8192cu

Optional Wireless Antenna Configuration.

DEVICE=$(iw dev | grep Interface | cut -d " " -f2)
sudo iw dev $DEVICE scan |egrep "SSID|signal|\(on"
echo "options rtl8192cu ant_sel=x" | sudo tee /etc/modprobe.d/rtl8192xx.conf
value of x = 1 - 4, value ox xx = ee or cu
sudo reboot