Raspberry Pi


This post describes setting up a WIFI connection on a Raspberry Pi via the terminal. For setting up WIFI from Raspbian, simply launch the WIFI Config utility from the desktop.

If you would like to use the Pi as a Wifi hotspot instead, try our recipe: RaspAP Wifi Hotspot

Setup WIFI on Raspberry Pi

  • First we're going to make sure our Raspbian operating system is all up to date with the latest drivers. To do this we'll run the following commands:
sudo apt update
sudo apt full-upgrade
  • We'll want to take a backup of the WIFI configuration file before we start to make changes.
sudo cp /etc/wpa_supplicant/wpa_supplicant.conf /etc/wpa_supplicant/wpa_supplicant.conf.bak
  • Next up we can edit the file with the nano editor
sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
  • Add the configuration as shown below. You'll need to swap "YOUR_SSID" and "YOUR_PASSWORD" for your WIFI name and password.
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev

  • Once done, save and close the nano editor

  • That should be all we need to do to get things going! Reboot your Pi with

sudo reboot
  • Once your Pi is back up and running, run the below to see if the change we have made has worked (there should be a wlan0 section or similar)
sudo ifconfig

Convenient Shortcut

In later versions of Raspbian, we have a great way to speed up the creation of your Wifi configuration. This is extremely convenient if you want to pre-configure your Pi with wifi settings, or change wifi settings for any reason.

  • Open up the SD card of your Pi on any computer
  • On the main partition (the only one visible for instance in Windows), add a pre-configured wpa_supplicant.conf to the root folder
  • Done: once your Pi boots again, the wpa_supplicant.conf file is copied over to the right location and your new wifi settings are applied