If you have installed Linux using a base image and not a GUI installer, and therefore need to connect to a WiFi network after the first boot, you can do so by following the steps outlined below.
Start by running wpa_cli.
scan
scan_results
add_network
set_network 0 ssid "SSID"
set_network 0 psk "PSK"
enable_network 0
save_config
quit
Now run dhcpcd.