How to Connect Raspberry Pi to Wi-Fi Command Line

This site contains affiliate links to products. We may receive a commission for purchases made through these links.

If you are using Raspberry Pi 3, it comes equipped with onboard WLAN (wireless LAN 802.11n) which is both Bluetooth and Wi-Fi adapter. Therefore, this means that you will only require the Raspberry Pi 3 in order to get connected to your Wi-Fi or a Bluetooth connection. The best part is that you will not require additional peripherals such as USB Dongles for Wi-Fi connection.

Understanding how to connect Raspberry Pi to Wi-Fi command line is vital and helps in carrying out various essential tasks. In this article, we shall be taking yours through how to connect your Raspberry Pi to a Wi-Fi command line. You should note that the whole process is relatively easy and does not require any advanced skills.

AdobeStock 266087580 1

Connecting Raspberry Pi to Wi-Fi command line

Before we go into detail of Wi-Fi setup of a Raspberry Pi 3, you should consider doing the following:

  • Using an SD card formatter, you should go ahead and format your microSD card.
  • Once that is done, you will download Raspbian Jessie OS.
  • The OS (.img file) should then be written on your microSD card with the use of Win 32 Disk Imager.
  • You should then enable the SSH by creating a blank file using the name SSH with no extension.
  • Insert your microSD in your Raspberry Pi, plug in your Ethernet cable and then go ahead and power on your Raspberry Pi.
  • Once that is done, you will scan for an IP address and then note down your Raspberry Pi’s IP address.
  • Start the PuTTY and then enter your Raspberry Pi’s IP address.
  • Once you are through, you will go ahead and login with the default password as well as username.

You should note that at this point, you will be able to visualize the IP address that is assigned to your Raspberry Pi. You should note your Raspberry Pi’s IP address since you will be using it to scan for the IP address once again when the Wi-Fi is set.

Set it up until the step is ideal for setting up your Wi-Fi. When you initiate your Wi-Fi and start getting connected to the network, you will proceed to the next step. Once you have login successfully to your Raspberry Pi with the use of an SSH client like PuTTY, you should go ahead and key in this command sudo iwlist wlan0 scan and then click Enter.

Once you enter the command, it will return a list with wireless networks which are near your Raspberry Pi. The line ESSID will identify the name of your network. When you have your network identified, you will go ahead and connect your Raspberry Pi to it. To do that, you will be required to make some changes in a wpa_supplicant.conf file.

You will go ahead and pass the Wi-Fi network’s name in the file along with the password. You will key in these commands in order to open the file sudo nano /etc/wpa_supplicant/wpa_supplicant.conf once that is done, you will click Enter. When you do this, you will come to notice that there are lines such as country =GB among others. Below existing content, you will key in this command: network+{ and then SSID=”your Wi-Fi’s name” and then PSK=”the password to your Wi-Fi” }

You should note that, if you have the above commands present in your wpa_supplicant file, you should consider editing them using the current Wi-Fi’s name as well as password. Once you have the command keyed in, you should go ahead and click CTRL+X in order to exit. When that is done, you will be asked if you would like to save your changes or not. In order to save, you will go ahead and type Y and Enter.

With that done, you will go ahead and turn on your Wi-Fi adapter and to do this; you will have to key in these commands sudo ifup wlan0 and sudo ifdown wlan0. Once you key in these commands, your Wi-Fi adapter will be turned on allowing you to connect your Raspberry Pi to your network.

However, if your Raspberry Pi fails to connect to your Wi-Fi network, or maybe you are not sure if it was connected successfully, you might consider rebooting your Raspberry Pi by keying in these commands sudo poweroff and sudo reboot. Once that is done, you will go ahead and disconnect LAN cable and then restart your Raspberry Pi. By doing so, it will be connected to your Wi-Fi network automatically. To confirm, you can scan for your Raspberry’s IP address once again.

After scanning, you will come to notice that your Raspberry Pi’s IP address has changed and you can use this new IP address to log in with the use of PuTTY SSH client. You can now login username and the password.

To check your connection, you can type this command in a PuTTY terminal ifconfig. By doing so, it will return all the details of your connection such as IP address, received bytes and transmitted among others.

You should note that ifconfig command will help you return all details of both Wi-Fi (wireless connection) and Ethernet (wired connection). Once you connect to your Wi-Fi network, you might consider further steps such as installing a VNC server as well as a viewer on your Raspberry Pi. You can as well enable VNC, access your Raspberry Pi’s desktop with a VNC client, among others.

Final Word

Connecting your Raspberry Pi to a Wi-Fi command line is relatively easy; all you have to do is log in to your Raspberry Pi with the help of PuTTY or any other SSH client that you find useful. By doing so, the whole process becomes easy once you adhere to the tips discussed in the article.

The entire process is easy and does not require any sophisticated skills to achieve it; this means that as a newbie, you can accomplish the whole process once you adhere to the tips discussed here. As we conclude, we hope that you find this article helpful as you connect your Raspberry Pi to a Wi-Fi command line.

About The Author