Setup WiFi from Command Line Console

Setting up WiFi from the GUI of Raspbian is easy, just click the wifi button on the top right, select your SSID, enter your details and away you go.
If however you don't want to use the GUI, or you are using say Raspbian Jessie Light, where there is no GUI, you need to do this from the command line. Don't worry, it's just as easy, you just need a couple of commands.

Before you start

First we need to scan for wireless networks. Before you do this you need to consider two things.

This may not be useful if your SSID is hidden (not tried it to be honest)

If are using MAC Filtering on your router, you need to add the MAC of the wireless dongle to your router configuration first.

If you are using MAC filtering, from the command line enter:

ifconfig

You will see an output as follows:

wlan0 Link encap:Ethernet HWaddr d5:6b:b0:99:46:86
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1826 errors:0 dropped:1183 overruns:0 frame:0
TX packets:183 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:216207 (211.1 KiB) TX bytes:24862 (24.2 KiB)

Enter HWaddr (d5:6b:b0:99:46:86 in this example) in to your router.

Find your Wireless Network