Connect to wifi in the command line

The wifi access point security will determine the way you connect to it.

If WEP (less secure)
http://askubuntu.com/questions/294257/connect-to-wifi-network-through-ubuntu-terminal#answer-294320

If WPA
http://askubuntu.com/questions/138472/how-do-i-connect-to-a-wpa-wifi-network-using-the-command-line#answer-138476

Configuring WPA
# view enabled connections
$ ifconfig

# view enabled and disabled connections
$ ifconfig -a

# To find out the name of your wireless card device. Look at the row that has some information in it, not ‘no wireless extensions’. In this example its wlan0.
$ iwconfig

# find wireless/wifi access points
$ sudo iwlist scan
$ nmcli dev wifi list # source
# an alternative can be “wavemon” if installed on your machine

# Add wifi network ssid and password
$ sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
# add to the bottom of file

network={
 ssid="your_wireless_ssid"
 psk="your_wireless_password"
}

# wpa_supplicant.conf is being included in /etc/network/interfaces. Another option would be to edit interfaces file directly. Example Below.

auto lo

iface lo inet loopback
iface eth0 inet dhcp

allow-hotplug wlan0
auto wlan0

iface wlan0 inet dhcp
	wpa-ssid "your_wireless_ssid"
	wpa-psk "your_wireless_password"

# restart connection. This is an alternative to restarting the computer
$ sudo ifdown wlan0
$ sudo ifup wlan0

# you should now see an ip address under “inet addr:”
$ ifconfig wlan0

# test internet connection
sudo ping google.com

# useful commands
# 10 Useful “IP” Commands to Configure Network Interfaces

$ ip addr show
$ ip route show

tag:
wireless interface, network, raspberry pi