Getting the Edimax EW-7811UN wireless adapter working on Linux

Edimax EW7811-UN

Edimax EW7811-UN Wireless USB Adapter

The Edimax EW7811-UN is a wireless USB adapter that complies with the 802.11b/g/n IEEE standards. The device has a Realtek RTL8188CUS based chipset which has support for Windows, Mac & Linux.

Support for this device should be available in version >= 3.0 of the Linux kernel through the use of the rtl8192cu module. This means that machines running Linux kernel 3.0 or greater should have support for this device straight out of the box. You can find out your current kernel version by running the command uname -r.

When the device is inserted to a USB port on the machine, the rtl8192cu module should be loaded. To see if it has been loaded correctly, run the command: lsmod | grep rtl8192cu. If that command returns nothing, you can try to load the module by running the command: sudo modprobe rtl8192cu.

Personally, my wireless network consists of two access points with the same ESSID on different channels. The rtl8192cu module appeared to have an issue with this type of setup. The device was able to see the wireless network but failed to connect to it when both access points were in range. The expected behaviour for this situation would be for the device to connect to the stronger access point and roam to the other if it’s signal strength improved.

At the time of writing, the manufacturers of the chipset, Realtek, have a newer version of the driver available on their website. The version that worked for me was: v3.3.2_3192 released 09/01/2012. This can be obtained from the Realtek website.

To install this module, first disconnect the USB device from your machine and remove the kernel module: sudo modprobe -r rtl8192cu. It should be stopped from being loaded at boot by adding the following line to the /etc/modprobe.d/blacklist.conf file:

blacklist rtl8192cu

Download the zip file containing the module from the Realtek website and unzip it. cd into the extracted directory and execute the install script: sh install.sh. Enter your sudo password when prompted. This script will compile the module and install it. The new module is called 8192cu. Insert the Edimax device into a USB port and check to see if the module has been loaded correctly: lsmod | grep 8192cu. If nothing is returned, the module can be loaded manually: sudo modprobe 8192cu.

It’s almost always a better option to use the module that’s supplied with the Linux kernel but in some cases the manufacturers drivers have better support and should be used instead.

Disabling auto-scroll on Synaptics touchpad driver

An update to the Synaptics touchpad driver for Linux was released recently. For some reason, auto scroll was enabled by default for me after the update. Auto scroll allows the touchpad to scroll of it’s own accord which might suit some but for me it was bit of an inconvenience.

To disable auto scoll, the following line had to be added to the synaptics configuration file (normally located in /etc/X11/xorg.conf.d/10-synaptics.conf):

Option "CoastingSpeed" "0"

That should be entered before the EndSection line.

Using lftp for automated backups

Due to a hard drive failure recently, I discovered an excellent ftp client called lftp. I needed a way to backup the important directories such as /home /etc /var/www etc. quickly before the drive failed completely. I had never used any ftp client in the past for automated backups because I couldn’t find one that did what I wanted.

I needed a way of mirroring local directories to a remote backup and it had to delete files that no longer existed locally, a trivial task for something like rsync but finding a FTP client that provided this proved unsuccessful until I came across lftp.

According to Wikipedia:

lftp is a command-line file transfer program (FTP client) for UNIX and Unix-like systems. It was written by Alexander Lukyanov, and is made available under the GNU General Public License.

lftp is available on most major Linux distributions and can be installed through your systems package manager.

Once you have it installed, you can launch it by running:

lftp username@hostname

You’ll be prompted for a password if required. You can do all the usual commands such as ls, cd, mkdir etc. and you can find out more commands by typing help.

The command that is of most interest to me is the mirror command. It mirrors a remote directory recursively ie. it copies the directories contents including sub directories. The mirror command itself takes a number of parameters:

-c, --continue          continue a mirror job if possible
-e, --delete            delete files not present at remote site
-s, --allow-suid        set suid/sgid bits according to remote site
    --allow-chown       try to set owner and group on files
-n, --only-newer        download only newer files (-c won't work)
-r, --no-recursion      don't go to subdirectories
-p, --no-perms          don't set file permissions
    --no-umask          don't apply umask to file modes
-R, --reverse           reverse mirror (put files)
-L, --dereference       download symbolic links as files
-N, --newer-than FILE   download only files newer than the file
-P, --parallel[=N]      download N files in parallel
-i RX, --include RX    include matching files
-x RX, --exclude RX    exclude matching files
-I GP, --include-glob GP        include matching files
-X GP, --exclude-glob GP        exclude matching files
-v, --verbose[=level]   verbose operation
    --use-cache         use cached directory listings
--Remove-source-files   remove files after transfer (use with caution)
-a                      same as --allow-chown --allow-suid --no-umask

Care should be taken when using the mirror command because by default the command mirrors a remote directory to the local file system so when you think you’re copying local files to a remote location, you’re actually overwriting your local files with the files from the remote server!
To mirror files from the local file system to the remote, the -R parameter should be passed to the mirror command:

mirror -R /path/to/local/ /path/to/remote/

You can delete files on the remote server that no longer exist on the local file system by passing the -e parameter to the command above:

mirror -Re /path/to/local/ /path/to/remote/

As from what can be seen above, there is a substantial number of options that can be passed to the mirror command. The only extra argument I use is –use-cache to speed up the transfer process.

You can run lftp from a bash script like so:

#!/bin/bash
lftp -u username,password ftphost << EOF
mirror -Re --use-cache /home/ /backup/
mirror -Re --use-cache /etc/ /backup/
mirror -Re --use-cache /var/www/ /backup/
quit 0
EOF

 

Then, all you have to do is add this script as a cron job and you’re good to go!