Setup wifi adapter in linux

This little guide should help with configuring a USB WiFi adapter in Linux – this was in Ubuntu 12.04 but should work for later releases and other Debian based Unix versions. I recently configured my Raspberry Pi to use a wiki dongle but this guide didn’t work for some reason. This guide still works though and is much preferable since it is entirely done on the command line. The Raspberry Pi guide (which I’ll add at a later date) makes use of some GUI elements so not great for a headless server use case.I use the Edimax EW7811-UN which is very cheap and complies with normal the 802.11b/g/n IEEE standards. The device has a Realtek RTL8188CUS based chipset which has support for Windows, Mac & Linux. It also works great in the Raspberry Pi.
When the device is inserted to a USB port on the machine, the rtl8192cu module should be loaded automatically.

Load wifi module driver
First, check if the driver is automatically loaded on your machine with

lsmod | grep 8192.

If the result shows that the “8192cu” driver module is loaded, you have nothing left to do to load the module. If the result is nil, continue.
If it shows some other “…8192…” driver, uninstall it with rmmod -r .
Find the latest linux driver download address from Edimax:
Go to the Edimax website
-> Downloads
-> Communications Network ICs
-> Wireless LAN ICs
-> IEEE 802.11b/g/n Single Chip
-> Software
-> “Software: Drivers and Utilities”
-> “Step 1. Select one or more models”: check the box by RTL8192CU) and use in the correct line below:

mkdir -p /home/USERNAME/wifidriver
cd -p /home/USERNAME/wifidriver
wget ftp://WebUser:wK9xBuD5@

Insert the Edimax device into a USB port and check to see if the module has been loaded correctly automatically:

lsmod | grep 8192cu 

If nothing is returned, the module can be loaded manually:

modprobe 8192cu

Configure wifi connection

Install dependencies and kill network management utilities for configuration:

apt-get -y install wpa_supplicant psmisc
sudo stop network-manager
sudo killall wpa_supplicant
sudo killall nm-applet

Perform the SSID & password config

wpa_passphrase "YOUR_ESSID" | sudo tee /etc/wpa_supplicant.conf

-> then type your password

wpa_supplicant –d wext -B -c /etc/wpa_supplicant.conf -i wlan0

If you get your IP address automatically assigned by your router (most users) by DHCP just use the following (Note that you may have configured your router to assign a static IP to your server but from your server’s perspective this is still an auto assignation from your router so do this):

dhclient wlan0

If you want to configure a static IP then use:

ifconfig wlan0

You should now be able to ping your router by IP:


Now add the default gateway using the IP address of your router:

route add default gw

You should be able to ping the net at large now (Google’s IP =


Add DNS. This one is Google’s free DNS service which is pretty fast and reliable so a great choice – however there are privacy implications which we’ll not get into here). You could also use your ISP DNS servers which you should have been given when you joined them or which will be the ones defined in your ISP provided modem/router.

echo "nameserver" | sudo tee /etc/resolv.conf

You should be done now, test by pinging Google:


Make persistent through a reboot

This will not last through a reboot, to make this persistent we need to make a little script:

mkdir –p /usr/bin/wifi_connect
nano /usr/bin/wifi_connect/scripts/

Add this:

wpa_supplicant -d wext -B -c /etc/wpa_supplicant.conf -i wlan0
dhclient wlan0
route add default gw
echo "nameserver" | sudo tee /etc/resolv.conf
chmod 755 /usr/bin/wifi_connect/

You should now add to crontab or rc.local to run at startup. Crontab is a task scheduling tool in linux, whereas rc.local is a script which runs at boot so you can add things to it to make them run at startup.
The easiest way I found to add to crontab is through Webmin (see this post for Webmin installation guide).

To manually add to crontab you can do this:

sudo echo '@reboot /usr/bin /wifi_connect/ xbindkeys' >> /etc/crontab

Or to add to rc.local:

cp /etc/init.d/rc.local /etc/init.d/rc.local.old
nano /etc/init.d/rc.local

Add this above ‘exit 0’:

sh /usr/bin/wifi_connect/

Useful sources

1 Comment

Leave a Reply

(email optional)