Migrate from https://cmakerhk.wordpress.com/2018/10/29/config-wifi-on-terminal-on-pi/
Set Up Network on the Raspberry Pi
If you will use a Ethernet cable to connect your Raspberry Pi to the internet, you can skip this step.For this section we will assume you have a Raspberry Pi 3, with built in WiFi.
Start by scanning for wireless networks:
pi@raspberrypi:~ $ sudo iwlist wlan0 scan
This will list all of the available WiFi networks. (It also confirms that your WiFi is working)
Now we need to open the wpa-supplicant file, to add the network you want to connect to:
pi@raspberrypi:~ $ sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
This will open the file in the Nano editor. Add the following to the bottom of the file (change wifiName
andwifiPassword
with the actual network name and password):
network={
ssid="wifiName"
psk="wifiPassword"
}
Press "Ctrl+x
" to save the code. Confirm with "y
", and confirm the name with "Enter
".
And reboot the Raspberry Pi:
pi@raspberrypi:~ $ sudo reboot
After reboot, log in again, and confirm that the WiFi is connected and working:
pi@raspberrypi:~ $ ifconfig wlan0
If the WiFi is working propery, the information displayed should include an IP address, similar to this:
inet addr:192.168.1.50
Write down that IP address, as we will use it to connect to the Raspberry Pi via SSH.