To configure a WiFi device from the command prompt, you would use the tool "iwconfig".
For example, this would setup a WiFi card to connect to an AP with the SSID "linksys".
Code:
iwconfig wlan0 essid "linksys" channel 6 rate "Auto"
Adjust the device name as needed (you mentioned wifi0 in your post), as well as channel and SSID. If you need encryption, check the man pages for iwconfig, which will give a better description then I can.