How to setup Wifi on Raspberry Pi

First do a search for wlans in the area with
sudo iwlist wlan0 scan

then open up wpa_supplicant.confg with

sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

At the bottom of the file add this

network={
ssid="Your SSID"
psk=Your wifi password"
}

To reload the wpa config file do a sudo ifdown wlan0 and then a sudo ifup wlan0

Verify that everything is working with sudo ifconfig