Open the wpa-supplicant configuration file using editor
sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
Add the following line to the bottom of the file
network={ ssid="ssid name"
psk="Password"
}
If you are using a hidden ssid then add one more line
network={
ssid="yourHiddenSSID"
scan_ssid=1
psk="Your_wifi_password"
}