If you Google, DuckDuckGo. or even Bing how to set up Wi-Fi on Raspbian CLI, there are a bunch of guides I've found while trying to solve the same problem.
Unfortunately, most of them are wrong. As of writing this I've just spent about half an hour running through a few of them, and they either have superfluous steps, don't work anyway, or use the GUI.
The absolute simplest way is, if you are performing a new installation, use New Out Of Box Software (NOOBS). If you connect to a Wi-Fi network from NOOBS before installing Raspbian, NOOBS will pre-configure Raspbian to connect to your Wi-Fi access point.
If you've installed Raspbian by flashing it to an SD card directly, or already have a Raspbian installation, all you have to do is edit /etc/wpa_supplicant/wpa_supplicant.conf
.
The default configuration looks like this (after configuring your Wi-Fi country with raspi-config
):
country=AU
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
To connect to a Wi-Fi network, all you have to do is add a network block below that, i.e.:
country=AU
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="MyWiFiNetwork"
psk="MySuperSecretPassword"
}
Reboot the Raspberry Pi, and it will automatically connect to your Wi-Fi network.
This all assumes that you have a Wi-Fi adapter supported by Raspbian, or built-in to the board. If you don't, fix that first. 😉