Posted on

How to enable your Raspberry Pi 3 and Zero W WiFi via terminal

Connecting your Raspberry Pi Boards, Raspberry Pi 3 and Raspberry Pi Zero W, to the WiFi is fairly intuitive if you have access to a graphical user interface of the various Raspian OS versions available.

However, there are some cases that you will have to work with only the terminal or even when you are in headless or SSH mode when the Raspberry pi is connected via LAN.

This guide will tell you how to setup your Raspberry Pi’s WiFi via terminal. You only need to know the name of your network (SSID) and its password

If you want to scan for available networks, you can use the command in a terminal (Linux) connected to your network:

$ sudo iwlist wlan0 scan

Check out for ESSID:"Mini-Mods" where "Mini-Mods" is the name of the WiFi (SSID).

Step 1

Open the terminal software in the Raspbian of your , type:

$ sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

The sudo command means that you are executing the subsequent commands with root privileges.

The command nano /etc/wpa_supplicant/wpa_supplicant.conf means you want to open the file wpa_supplicant.conf in the /etc/wpa_supplicant/ directory using the nano terminal editor.

Step 2

Edit the wpa_supplicant.conf file and add the following at the bottom of the file:

In the example below, replace the “Mini-Mods” with your SSID and “password” with your network password, respectively.

network={
ssid="Mini-Mods"
psk="password"
}

If your preferred network doesn’t require a password, you can add the following instead,

network={
ssid="Mini-Mods"
key_mgmt=NONE
}

For hidden networks,

network={
ssid="Mini-Mods"
psk="password"
scan_ssid=1
}
Step 3

That’s it! Close and save the file by typing CTRL+X, hit y and then ENTER. If your Pi hasn’t connected yet, reboot by typing

$ sudo reboot