Categories
Design

How to setup wi-fi on your raspberry pi via the command line

Jason Fitzpatrick is the Editor in Chief of LifeSavvy, How-To Geek’s sister site focused life hacks, tips, and tricks. He has over a decade of experience in publishing and has authored thousands of articles at Review Geek, How-To Geek, and Lifehacker. Jason served as Lifehacker’s Weekend Editor before he joined How-To Geek. Read more.

How to setup wi-fi on your raspberry pi via the command line

You configured your headless Raspberry Pi just the way you want it, it’s settled in and running smoothly, but suddenly you want to move it away from its Ethernet tether with a Wi-Fi module. Skip hooking it back up to all the peripherals and quickly add in Wi-Fi support from the command line.

Why Do I Want to Do This?

If you’re a Raspberry Pi enthusiast (or quickly becoming one), you know how annoying it can be to realize that your headless Pi project now needs yet another little tweak that likely necessitates hooking up a monitor and keyboard/mouse to the box.

The best way to avoid falling into that trap is to configure your Raspberry Pi for remote access. Once you have that configured, however, you still need to know how to do tasks remotely that would previously be handled by a GUI interface (like turning on the Wi-Fi). Today we’re going to walk you through the technical (but simple) way to remotely connect to your Pi and activate a Wi-Fi add-on dongle.

What Do I Need?

For this tutorial you’ll need the following items:

  • 1 Raspberry Pi unit with Raspbian installed (this technique should work on other distributions, but we’re using Raspbian)
  • 1 Ethernet connection to Pi unit (necessary for activating the Wi-Fi functionality remotely)
  • 1 Wi-Fi Dongle (we use this model on all our Pi units with great success)

If you don’t use this Wi-Fi dongle model, we strongly recommend researching the model you intend to purchase to see if it is well supported. To that end, the USB Wi-Fi adapter section of the RPi wiki is very helpful.

In addition to the above items, you need to take a moment to check the configuration of the Wi-Fi node you intend to connect your Raspberry Pi unit to: you’ll need to make note of the SSID, password, and encryption type/method (e.g. the node is using WPA with TKIP shared-key encryption).

Enabling the Wi-Fi Dongle via the Terminal

To get started, power up your Raspberry Pi unit without the Wi-Fi dongle attached. At this point, the only network device should be the onboard Ethernet NIC (which you have connected to your network via Ethernet cable so you can remotely access the headless device).

Connect to your Pi via SSH to access a remote terminal prompt. (If you have not yet configured your device for remote access in this fashion, please review the following tutorial).

At the prompt, enter the following command:

In the nano text editor, you’ll see something like this:

iface lo inet loopback
iface eth0 inet dhcp

That’s the very basic configuration that governs your Pi’s Ethernet connect (indicated by the eth0 portion). We need to add on a very minor bit to enable the Wi-Fi dongle. Use the arrow keys to move down below the existing entry and add the following lines:

allow-hotplug wlan0
iface wlan0 inet dhcp
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp

Once you’ve annotated the file, press CTRL+X to save the file and exit the nano editor. At the prompt again, enter the following command:

sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

Compare the contents of the file, if it exists, to the following code. If the file is empty, you can use this code to populate it. Take note of the commented lines (indicated by the # marks) to reference which variable you should use based on your current Wi-Fi node configuration.

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

network= <
ssid=”YOURSSID”
psk=”YOURPASSWORD”

# Protocol type can be: RSN (for WP2) and WPA (for WPA1)
proto=WPA

# Key management type can be: WPA-PSK or WPA-EAP (Pre-Shared or Enterprise)
key_mgmt=WPA-PSK

# Pairwise can be CCMP or TKIP (for WPA2 or WPA1)
pairwise=TKIP

#Authorization option should be OPEN for both WPA1/WPA2 (in less commonly used are SHARED and LEAP)
auth_alg=OPEN
>

When you’re done editing the file, press CTRL+X to save and exit the document. Now is the time to unplug the Ethernet cable and plug in the Wi-Fi dongle.

At the command prompt, enter the following command:

When the device finishes rebooting, it should automatically connect to the Wi-Fi node. If for some reason it fails to appear on the network, you can always plug the Ethernet cable back in to double check the two files and the variables you altered.

Have a Raspberry Pi related tip, trick, or a tutorial you’d love for us to write? Sound off in the comments below.

Setting up Wifi by Hand (Advanced)

New Subscription

Please sign in to subscribe to this guide.

You will be redirected back to this guide once you sign in, and can then subscribe to this guide.

To configure Wifi you will need to edit the file /etc/wpa_supplicant/wpa_supplicant.conf. There are two ways to do this as described below. Use whichever is most convenient for your setup and situation.

With either approach, you’ll want the contents of the file to be what is shown below. Replace YOURSSID and YOURPASSWORD with whatever is used for your network setup.

This approach will allow you to configure Wifi by creating and editing the file directly on the SD card in another PC. The /boot partition is FAT formatted which is readable by most PC’s. So you can simply insert the SD card in a USB reader and a boot folder should show up.

If you create a wpa_supplicant.conf file in /boot, it will be copied to the main partition’s /etc/wpa_supplicant location at boot time,replacing whatever is there. It will then be deleted from /boot, so you won’t see it there if you go looking.

So just use whatever text editor (not word processor) you want on your PC to create the file in /boot, like this:

How to setup wi-fi on your raspberry pi via the command line

Save the file and safely remove the SD card from your PC. Put it in the Raspberry Pi and power it up. If all goes well, it should copy the file over and connect to your Wifi.

This is the more direct approach – you edit the file directly on the Raspberry Pi. This approach works good if you are already connected to the Raspberry Pi via a console cable or monitor.

Since this file requires elevated privileges to access, you’ll need to open it with sudo.

How to setup wi-fi on your raspberry pi via the command line

Then add the contents. Don’t forget to actually change YOURSSID and YOURPASSWORD.

How to setup wi-fi on your raspberry pi via the command line

Press CTRL-X and then Y to save and and exit. Then run the following command to have the file read and try to connect to your Wifi.

How to setup wi-fi on your raspberry pi via the command line

This guide was first published on Dec 10, 2012. It was last updated on Dec 10, 2012.

This page (Setting up Wifi by Hand (Advanced)) was last updated on Jan 22, 2022.

How to setup wi-fi on your raspberry pi via the command line

You’ve set up your headless Raspberry Pi the way you want it, it’s installed and working fine, but suddenly you want to pull it away from its Ethernet cable with a Wi-Fi module. Avoid reconnecting it to all devices and quickly add the Wi-Fi support from the command line.

Why do I want to do this?

If you’re a Raspberry Pi enthusiast (or quickly become one) you know how annoying it can be to realize that your headless Pi project now needs another little tweak that probably requires plugging in a monitor. and a keyboard / mouse at the box.

RELATED: Everything you need to know about getting started with the Raspberry Pi

The best way to avoid falling into this trap is to configure your Raspberry Pi for remote access. Once you’ve set this up, however, you should still know how to perform remote tasks that would previously be handled by a GUI (like turning on Wi-Fi). Today we’re going to walk you through the technical (but simple) way to remotely connect to your Pi and activate a complementary Wi-Fi dongle.

What do i need?

For this tutorial, you will need the following:

  • 1 Raspberry Pi unit with Raspbian installed (this technique should work on other distributions, but we are using Raspbian)
  • 1 Ethernet connection to the Pi unit (required to enable remote Wi-Fi functionality)
  • 1 Wi-Fi Dongle (we use this model on all our Pi units with great success)

If you are not using this Wi-Fi dongle model, we strongly recommend that you research the model you intend to purchase to see if it is well supported. To this end, the USB Wi-Fi adapter section of the RPi wiki is very useful.

In addition to the above items, you should take a moment to check the configuration of the Wi-Fi node that you intend to connect your Raspberry Pi unit to: you will need to write down the SSID, password and encryption type / method (for example, the node uses WPA with TKIP shared key encryption).

Activation of the Wi-Fi dongle via the terminal

To get started, turn on your Raspberry Pi unit without the attached Wi-Fi dongle. At this point, the only network device should be the built-in Ethernet network card (which you have connected to your network via an Ethernet cable so that you can remotely access the headless device).

Connect to your Pi via SSH to access a remote terminal prompt. (If you have not yet configured your device for remote access in this way, please see the following tutorial).

At the prompt, enter the following command:

In the nano text editor, you will see something like this:

iface lo inet loopback
iface eth0 inet dhcp

This is the very basic configuration that governs the Ethernet connection of your Pi (indicated by the eth0 part). We need to add a tiny bit to activate the Wi-Fi dongle. Use the arrow keys to go down below the existing entry and add the following lines:

allow-hotplug wlan0
iface wlan0 inet dhcp
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp

Once you have annotated the file, press CTRL + X to save the file and exit the nano editor. When prompted again, enter the following command:

sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

Compare the contents of the file, if it exists, to the following code. If the file is empty, you can use this code to fill it. Take note of the commented lines (indicated by # marks) to reference the variable you should use based on your current Wi-Fi node configuration.

# Protocol type can be: RSN (for WP2) and WPA (for WPA1)
proto=WPA

# Key management type can be: WPA-PSK or WPA-EAP (Pre-Shared or Enterprise)
key_mgmt=WPA-PSK

# Pairwise can be CCMP or TKIP (for WPA2 or WPA1)
pairwise=TKIP

#Authorization option should be OPEN for both WPA1/WPA2 (in less commonly used are SHARED and LEAP)
auth_alg=OPEN

When you are done editing the file, press CTRL + X to save and exit the document. Now it’s time to unplug the Ethernet cable and plug in the Wi-Fi dongle.

At the command prompt, enter the following command:

When the device has finished restarting, it should automatically connect to the Wi-Fi node. If for some reason it does not appear on the network, you can always reconnect the Ethernet cable to check both files and check them. variables you changed.

RELATED: How to configure your Raspberry Pi for remote shell, desktop, and file transfer

Got a Raspberry Pi tip, tip, or tutorial you’d like us to write? Sound off in the comments below.

Let’s learn how to configure WiFi on Raspberry Pi 4 Model-B. We can either use the command prompt (terminal) or graphical user interface to setup wireless network. In this post, we will use a command prompt to setup our network credential onto Raspberry Pi 4. This will enable Raspberry Pi to access the internet from home router. We will complete setup of a wireless network by running just a few commands.

The first step is to login Raspberry Pi 4. Then open Terminal –> Type sudo iwlist wlan0 scan –> Hit Enter. This command will scan and list all the available WiFi networks with all necessary information. We will get our home network details into this list (say for example SSID which is a name of wifi network). This will help us to make sure network (that we want to connect) is available or not for Raspberry Pi.

How to setup wi-fi on your raspberry pi via the command line

The next step is to add network details on Raspberry Pi 4. Run this command sudo nano /etc/wpa_supplicant/wpa_supplicant.conf This will open up wpa_supplicant.conf file. Add these few lines of code and replace your network information.

Our file will look something similar as shown in the picture below:

How to setup wi-fi on your raspberry pi via the command line How Setup WiFi on Raspberry Pi 4

Once we have added WiFi network details. We will have to save this file by pressing CTRL+O and then CTRL+X . And then simply run sudo reboot command which will reboot the Pi. When Raspberry Pi restarts, we will connect to the internet without using any Ethernet cable.

Live Demo: How to Configure WiFi on Raspberry Pi 4

Now we know How to configure WiFi on Raspberry Pi 4. In next tutorial, we will learn about GPIO Pins on Raspberry Pi 3. GPIO Pins are Digital Input Output Pins to control external devices using Raspberry Pi 4. I hope you will find this tutorial educational and entertaining. Thanks for reading and see you in next tutorial.

Published by Soren on November 5, 2016

This is an updated guide showing you how to connect your Raspberry Pi to your home WiFi network in cases where you do not have a graphical user interface for your Raspberry Pi.

For this guide you need a Raspberry Pi – and unless you’re using the Raspberry Pi 3 – an external USB WiFi Dongle like this one.

Connecting to your Raspberry Pi

First step is connecting to your Raspberry Pi in order to get to a terminal. You can do this by connecting your Raspberry Pi to a monitor and keyboard – or connecting via Ethernet like described in this guide.

Login to the Raspberry Pi with the default Raspberry Pi credentials:

Getting your network information

For the purpose of this guide we will be connecting to a WiFi network with the following information:

  • SSID (Network Name): Test Wifi Network
  • PSK (Password): SecrectPassWord

Every time you see this network name and password in the guide you need to change them to the network name and password of your local network.

If you need to find the network name of your local network you can run the following command in the Raspberry terminal:

This will list all the networks in your vicinity along with some useful information for each network. To find your network name look for something that look like: ESSID:”Test Wifi Network”.

Configuring your WiFi network

To tell the Raspberry Pi to automatically connect to your WiFi network you need to edit a file called: wpa_supplicant.conf.

To open the file in nano type the following command:

Scroll to the end of the file and add the following to the file to configure your network:

Remember to replace this with your own network name and password.

Save and close the file by pressing Ctrl+X followed by Y. At this point the Raspberry Pi should automatically connect to your network.

You can check your network connection by running the following command:

If the output looks something like this (with an inet addr) you are connected:

inet addr:192.168.1.216

Sometimes the Raspberry Pi will not connect automatically and require a reboot to connect.

If it doesn’t connect after waiting 2-3 minutes try to reboot the pi using the following command:

Using Ethernet cable to connect with the Internet is too old fashion and does not provide mobility. So the best option we have is to connect Raspberry Pi To WiFi network. This article will help you connect your Raspberry Pi to Wifi network via the command line in your Raspberry Pi. We assume you have already set up your Raspberry Pi, if not then visit this link if you want to headless setup Raspberry Pi in a matter of time.

How to setup wi-fi on your raspberry pi via the command line

This is a very easy trick and has only a few steps (commands). Let’s get you to familiarize with the whole process.

In this article, we will show you how you can get the list of the WiFi networks that you can connect your RaspberryPi too from the terminal only. After that, we will update one network configuration file in the RaspberryPi system files to allow it to connect automatically to the WPA network whenever it restarts without asking for the password every time. Please keep in mind that to if you don’t know the password of the network then this article won’t be able to help you to connect your RaspberryPi to the required WiFi network. Once you successfully update the file, RaspberryPi automatically would try to the network or else you can force the connection process by restarting the RaspberryPi if you don’t have enough patience.

So let’s get started.

Step 1:Â Turn Raspberry Pi ON and start it’s terminal or any terminal which is connected to the Raspberry Pi (If you are using it headlessly).

How to setup wi-fi on your raspberry pi via the command line

Step 2:Â Enter the command given below in the command line to list all available WiFi networks to find your network’s ESSID.

sudo iwlist wlan0 scan

How to setup wi-fi on your raspberry pi via the command line

Step 3:Â Find or trace your network’s ESSID by find option in terminal or manually to copy it so there will be no chances of failure.

Step 4: Open the WPA-supplicant configuration file in nano.

sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

How to setup wi-fi on your raspberry pi via the command line

Step 5:Â Add the code given below at the end of the file with correct information.

Step 6: Now press Ctrl + X Exit the File.

Step 7: It will ask to save the changes or not, Press to save the changes in the file. Then Hit Enter/Return.

Step 8: That’s all. Your work is over.

After a few seconds, the wpa-supplicant file will notice some changes have occurred so it will try to connect to the network.

NOTE: Don’t forget to attach WiFi Connector to your Raspberry Pi else it won’t be able to connect to WiFi.

If it is not getting connected and you want to force connect, then reboot your Raspberry Pi with sudo reboot command in the command line.

If Raspberry Pi is still not connected To WiFi network, check your password and ESSID are correct.

If you have any query related to this article then feel free to ask in the comment section. We will be glad to help you out.

How to setup wi-fi on your raspberry pi via the command line

Note: This tutorial is for the Raspberry Pi 2 and earlier versions that need a USB WiFi adapter. To set up WiFi on the Raspberry Pi 3, please see this tutorial.

In a previous tutorial, I explained how to establish an SSH connection to your Raspberry Pi over ethernet without using an external keyboard or monitor. Connecting with an ethernet cable, is great if you want to leave it connected to your router with a physical cable. But I prefer to use WiFi, which gives me a lot more flexibility with where I can keep my Pi while it’s running.

Be careful when choosing a WiFi adapter for the Raspberry Pi though, because not all of them will work out of the box. I found that this one on Amazon works great without any driver installations needed.

Still, there are a couple things that need to be set up for any WiFi adapter to work properly with your Raspberry Pi. I’ll go through them step by step in this article. You should already have set up the SSH connection over ethernet, as described in this post.

This video will walk you through the steps, but see below for more details:

Edit the Network Interfaces File

With your USB WiFi adapter plugged into the Pi, power up the Pi and connect it to your internet router with an ethernet cable just like we did in the last tutorial. Now SSH into your Pi with PuTTY, and get to the command prompt:

How to setup wi-fi on your raspberry pi via the command line

We’ll need to change a few things in the /etc/network/interfaces file.

To edit this file, we’ll use the Raspbian text editor Nano. Enter this at the command prompt to edit the file:

sudo nano /etc/network/interfaces

Pro Tip: If you ever want to copy something from your laptop/desktop and paste it into PuTTY, just copy it, then right click with your mouse where you want to paste it into PuTTY.

Replace the code in the file with this code:

Afterwards, the file should look like this:

How to setup wi-fi on your raspberry pi via the command line

Then type Ctrl-X to exit, and Y to save the changes.

Edit the wpa_supplicant.conf File

Now we need to make some changes to the /etc/wpa_supplicant/wpa_supplicant.conf file. Open the file in Nano by entering this at the command prompt:

sudo nano /etc / wpa_supplicant / wpa_supplicant.conf

Replace the code in the file with this code:

The file should look like this:

How to setup wi-fi on your raspberry pi via the command line

The entry for ssid=”YOUR WIFI NETWORK NAME” is the name of your wireless network, typed exactly as it appears when you connect to your WiFi from another computer. The letters are case sensitive, and the ” ” marks should be left in.

The entry for psk=”YOUR WIFI PASSWORD” is the password you normally use to login to the network.

Re-enter your network name in the id_str=”YOUR WIFI NETWORK NAME” line.

Now press Ctrl-X and Y to exit and save changes to the file.

Now shutdown the Pi by entering sudo poweroff at the command prompt. Unplug the Pi from power, and disconnect the ethernet cable from your internet router. Now restart the Pi.

Find the New Local IP Address

Up to this point we were SSHing to the Pi with the local IP address on the ethernet port. The IP will be different on WiFi, so you’ll need to use Advanced IP Scanner to find the new one. Once you get that, SSH with PuTTY using the IP address for the WiFi port.

Test the WiFi Connection

After you log back into the Pi, check the status of your WiFi connection by typing iwconfig at the command prompt. Your WiFi network name should appear under ESSID: “YOUR WIFI NETWORK NAME” , in my case it’s “Siamese” . If your WiFi connection is successful, you’ll see a message like this:

How to setup wi-fi on your raspberry pi via the command line

If you see something like Link Quality=0/100 or Signal Level=0/100 in the wlan0 section, it means the Pi isn’t connected to WiFi. Go back and make sure that you have entered everything exactly as it’s shown in the images.

Another way to test your Pi’s WiFi connection to the internet is by pinging Google. Do this by entering sudo ping www.google.com :

How to setup wi-fi on your raspberry pi via the command line

PuTTY is great if all you need to do is access your Raspberry Pi from the command line. However, many features are only available through the Raspbian desktop. In order to access the desktop remotely, we need to install and configure a Remote Desktop Connection. Read How to Access the Raspberry Pi Desktop With a Remote Desktop Connection for a tutorial on how to do that.

Thanks for reading! Feel free to leave a comment if you’re having trouble setting this up and I’ll do my best to help you out. And be sure to subscribe to get an email when we publish new tutorials!

You can connect your Raspberry Pi to a WiFi network by plugging in a USB Wifi adapter to the Raspberry Pi’s USB port.

Make sure you buy one of the USB adapters that are supported by the built-in drivers to avoid the pain of finding the correct driver and installing it. A list of supported USB Wifi dongles and their performance can be found on the link Supported USB WiFi Dongles

Once you plug in the USB adapter, you can check if your Raspberry Pi OS recognized your dongle, by issuing command:

The above output shows the USB device was recognized by Raspbian.

Now check ifconfig output and locate wlan interface, usually wlan0 . In the ifconfig output, eth0 is the built-in wired interface, lo is loopback and the interface name starting with wlan is the USB Wifi interface.

In my case my wireless interface is wlan0. The wlan0 wireless interface has to be configured for DHCP by editing the /etc/network/interfaces file. Make sure it has the following lines

Now we need to configure the SSID and password of our WiFi network. Scan for available wireless networks using the command below:

The output is rather long and complicated. If you are in the range of your Wifi network it will show up in the scan.

Now add the SSID and password provided by your Wifi network provider (usually found at the back of the router) to the configuration file /etc/wpa_supplicant/wpa_supplicant.conf

Save by pressing Ctrl+X and y enter.

Now bring the interface down, wait for few seconds and bring it back up again.

The interface is now connected and acquired an IP address. You may verify by running ifconfig again.

If the interface is still not connected, you may reboot the machine and check again. In some cases you may need to add extra lines to /etc/wpa_supplicant/wpa_supplicant.conf to specify advanced Wifi configurations as shown in the example below

These configuration parameters can be understood from the result of iwlist scan.

  • proto – Protocol type can be RSN or WPA (for WPA2 and WPA1 respectively).
  • pairwise – CCMP or TKIP (for WPA2 and WPA1 respectively).
  • auth_alg – authentication algorithm, can be OPEN for both WPA1/WPA2

After configuration changes, save the file and restart the interface. Check using ifconfig or iwconfig.

Sometimes the USB Wifi adapter requires more power than the Pi USB port can provide, specially if your router or Wifi hotspot is far away from your Raspberry Pi and you need to send large amounts of data over a weak connection. In this case you can get better performance by plugging the adapter to a powered USB hub.

Connecting to Wi-Fi is easy!

We are going to take the more universal approach and use the command line. However, if you have Raspbian/Raspberry Pi OS desktop you can use the upper right-hand connection control icon to enable Wi-Fi. If you are using the command line only distro, you can utilize raspi-config and you’ll find Wi-Fi settings under Network Options.

Our universal method does not use raspi-config or the connection control icon in the GUI. This will also work over SSH.

Just show it to me!

$ sudo rfkill unblock wifi
$ sudo sh -c “wpa_passphrase ‘ssid’ ‘password’ >> /etc/wpa_supplicant/wpa_supplicant.conf”
$ sudo wpa_cli -i wlan0 reconfigure

Done! Seriously, you are done. You can stop reading if you’re busy and need to get on with your day.

Wait! What just happened? Let’s break it down.

First we enable the wireless interface (wlan0)
$ sudo rfkill unblock wifi
We can check this with the ifconfig command
$ ifconfig
You’ll see an entry for the wlan0 interface. We unblocked wifi because it may have been blocked either by this command
$ sudo rfkill block wifi
or Wi-Fi may have been disabled in the GUI (upper right-hand connection control icon). By issuing this command, we ensure the interface will always be enabled.

Our next command does all the magic to get connected to Wi-Fi in a single statement.

$ sudo sh -c “wpa_passphrase ‘ssid’ ‘password’ >> /etc/wpa_supplicant/wpa_supplicant.conf”

The file /etc/wpa_suplicant/wpa_supllicant.conf simiply contains our Wi-Fi connections information. We use wpa_passphrase ‘ssid’ ‘password’ to generate the proper entry needed for this file. Replace ‘ssid’ and ‘password’ with your Wi-Fi ssid and password. The output is appended to the file /etc/wpa_supplicant/wpa_supplicant.conf

Take a look at the file with the command
$ sudo cat /etc/wpa_supplicant/wpa_supplicant.conf
You’ll see something like this at the end of the file

You can see our new entry. Our pre-shared key has been encrypted! You can edit this file and remove the un-encrypted (commented out) psk if you’d like.

At this point we are done. After some time has passed the Wi-Fi changes we made will take effect. To get these changes working right now we issue the command
$ sudo wpa_cli -i wlan0 reconfigure

To see it in live, check out the video below from our YouTube channel!

Jul 2, 2021 · 2 min read

How to setup wi-fi on your raspberry pi via the command line

This version of Raspberry Pi Zero, its main feature is the wifi connection, so you can control it remotely by stablishing an SSH connection without the need to use monitor/keyboard (Headless).

To connect to a Wi-Fi network, you have to configure the wpa_supplicant.conf fiile using the following command line.

Then you have to add a new wifi network.

After this you have to reboot your raspberry.

Another way to configure your raspberry is through the use configuration menu using the following command:

After this, the following menu will appear as show in the image.

How to setup wi-fi on your raspberry pi via the command line

Then y o u have to choose the firts option (1), then select the option (S1) Wireless LAN.

How to setup wi-fi on your raspberry pi via the command line

Next you have to enter the name and password of your Wi-Fi network. Reboot your raspberry.

By default, the current version of Raspbian has SSH disabled, so lets enable it. Make use of the following command to enable it:

Your Pi is now ready to have an SSH connection.

This is a step by step guide to connecting your Raspberry Pi with your Mac.

1. First find your Network Preferences.

In the upper right hand corner of your screen, click on the wifi icon. How to setup wi-fi on your raspberry pi via the command line

2. Setup your Ethernet Preferences

After clicking “Open Network Preferences”, select your Ethernet connection on the left hand side of the box. Check that you have “Using DHCP” selected for “Configure IPv4” option. And check that “Location” at the top of the dialog box has “Automatic” selected for your network configuration.

How to setup wi-fi on your raspberry pi via the command line

Check that you’ve selected “Using DHCP”

How to setup wi-fi on your raspberry pi via the command line

3. Setup the Hardware.

Plug one end of your ethernet cable into your Raspberry Pi, and the other into your computer ethernet card. Power the Raspberry Pi up. You should see all of the lights flashing on the Raspberry Pi!

4. Test for Connection

To test if your Pi is connected on the network will open the windows command line and type

Open the terminal on your Mac. Press “Command Space”, which opens Spotlight. Type “Terminal” and the terminal will come to the top. Click on the terminal icon. In the Bash command line, type

5. Connect to your Raspberry Pi Using SSH

You can log into your Raspberry Pi using Bash on your Mac. Again, we’ll open up a new terminal: Press “Command Space”, which opens Spotlight. Type “Terminal” and the terminal will come to the top. Click on the terminal icon. In Bash, type

You’ll be prompted to verify you’re trying to login to the Raspberry Pi. Type “yes” an press return. Type the password. The default password for the BrickPi image is “raspberry”. Type “raspberry” and press return. Boom! You’re logged into your Raspberry Pi and ready to start programming a LEGO robot!

How to setup wi-fi on your raspberry pi via the command line

6. Connect to your Raspberry Pi Using VNC

If you’re more comfortable working in the Raspberry Pi Desktop environment, you can use a program called VNC to login and run programs on the Raspberry Pi.

First, install VNC Viewer on your Mac. VNC Viewer is free. You can download VNC Viewer here.

How to setup wi-fi on your raspberry pi via the command line

Click download on the “VNC Viewer for Mac OS X”. You will be prompted for a name and e-mail address.

Agree to the terms and click “Download”.

How to setup wi-fi on your raspberry pi via the command line

Install VNC Viewer by double clicking on the downloaded file.

When VNC View opens, type the following into the VNC Server box:

The colon and number 1 afterwards are important, don’t leave them out!

Finally, continue through VNC’s warning message about the unencrypted connection.

How to setup wi-fi on your raspberry pi via the command line

When prompted for the password, the password is “raspberry” Congratulations! You’re in!

How to setup wi-fi on your raspberry pi via the command line

An essential part of the Internet of Things is having objects speak to each other wirelessly. Raspberry Pi’s are a great way to do this because of the low cost of available Wifi dongles and the ease of setting them up.

How to setup wi-fi on your raspberry pi via the command line

In a previous tutorial we covered how to setup your Raspberry Pi WiFi by manipulating the /etc/network/interfaces file directly. While this approach is pretty straightforward, it has some disadvantages:

It doesn’t handle all types of encryptions (WPA, WPK, etc.)

If the connection drops, it won’t be re-established automatically

It doesn’t provide a simple interface to manage the connection, making it hard to troubleshoot

Hardware Needed

In this tutorial we’ll setup wifi on Raspberry Pi using the TP-Link TL-WN725N usb wifi adapter.

Step 1

First of all, make sure the WiFi dongle is plugged in before booting up your Raspberry Pi. Once you’re prompted with the command line, install the wicd-curses:

Step 2

Wicd is a well known package to manage wifi networks from any Linux computer. Once installed, you can execute it:

You will be welcomed with a screen showing the available wifi networks. If your network is not showing up, you can try hitting Shift+P and then in the “Wireless interfaces” section type wlan0.

Step 3

How to setup wi-fi on your raspberry pi via the command line

Press F10 and then Shift+R to refresh the connections and then select your network:

How to setup wi-fi on your raspberry pi via the command line

Check the box “Automatically connect to this network” and then select the encryption type. Type your WiFi password and press F10 and then Shift+C to connect. Once you’re connected, type Shift+Q to exit wicd-curses.

You should be all set! You can check your Internet connection by pinging any website:

How to setup wi-fi on your raspberry pi via the command line

What to do next?

What can you do with a wifi-enabled Raspberry Pi? actually a lot. In the Internet of Things (IoT) space, you could create projects like:

A wireless temperature monitor

Have your pet text you when it needs something (like your Fish sending you an SMS if there’s low oxygen in the water)

We hope you enjoyed this as much as we do! Let us know your comments or inquiries. If you already have a project in mind, click below to get started!

Content originally published in Ubidots Blog on May 6, 2014.

If you have a Raspberry Pi 3, WiFi is built into the Pi, if you have a Pi2 or earlier model, then you’ll need a wifi dongle. You can check to see if your wifi dongle is compatible here. You may want to use an USB WiFi dongle, then see here.

NOTE: In order to use the WiFi on the Raspberry Pi, you will need to first configure the WLAN Country via raspi-config . It’s under menu 5 Localisation options in raspi-config . You can start raspi-config from the RetroPie menu in EmulationStation or from the command line with sudo raspi-config .

There are 5 main methods to configure Wifi:

WiFi Module

You can access this from the Retropie menu in emulationstation (you can also access it from option 3 in the RetroPie setup script):

How to setup wi-fi on your raspberry pi via the command line

It will open into this menu:

How to setup wi-fi on your raspberry pi via the command line

Choose your SSID from a list:

How to setup wi-fi on your raspberry pi via the command line

Type your Wifi Password (You may need to wait a bit after you finish for the configurations to save)

How to setup wi-fi on your raspberry pi via the command line

After it’s done configuring you should see your wifi info in the original menu:

How to setup wi-fi on your raspberry pi via the command line

Connecting to WiFi Without a Keyboard

If you wish to connect to wifi without needing an extra keyboard you can add a file to the boot partition of the sd card called wifikeyfile.txt

place your network details here (note only works on WPA networks)

You can then access the wifi module and select the option to “Import wifi credentials from /boot/wifikeyfile.txt “

How to setup wi-fi on your raspberry pi via the command line

Connecting to WiFi Without a Keyboard

Starting with Raspbian Stretch, loading the wifikeyfile from the setup script is not necessary.

Create a file called wpa_supplicant.conf in the boot partition using the following template. (This will be moved at boot to the /etc/wpa_supplicant directory ).

Make sure to include the RETROPIE CONFIG . lines as shown to ensure that the RetroPie-Setup wifi configuration module will be able to cleanly edit/delete your configuration if you wish to change it later.

Wifi will not start up if you have an hard wired ethernet connection. After disconnecting the ethernet cable you’ll need to reboot to get Wifi started.

If you want ssh to be enabled by default as well you can create a blank file called ssh in the boot partition too. This is a ‘flag’ file and will be deleted during boot after ssh is enabled.

Manual Configuration (Interfaces)

sudo nano /etc/network/interfaces

WPA/WPA2

you can also add wireless-power off at the end if you have issues with your wifi dongle turning off and on a lot and not being able to maintain a connection.

Open Network

Hidden SSID

Static IP

The following only applies to Raspbian Jessie

You can use the default /etc/network/interfaces

Then you’ll need to edit /etc/dhcpcd.conf and add at the top modifying it for your own router and IP address:

If you want a static IP with ethernet then change it to:

sudo reboot for changes to take effect.

on reboot (if configured correctly) your wifi will be working.

Manual Configuration (WPA_Supplicant)

Taken from the Raspberry Pi Foundation here:

This method is suitable if you do not have access to the graphical user interface normally used to set up WiFi on the Raspberry Pi. It is especailly suited for use with a serial console cable if you don’t have access to a screen or wired Ethernet network. Also note that no additional software is required; everything you need is already included on the Raspberry Pi.

Getting Network Details

To scan for WiFi networks, use the command sudo iwlist wlan0 scan. This will list all available WiFi networks along with other useful information. Look out for:

ESSID:”testing” . This is the name of the WiFi network.

IE: IEEE 802.11i/WPA2 Version 1 . This is the authentication used; in this case it is WPA2, the newer and more secure wireless standard which replaces WPA1. This guide should work for WPA or WPA2, but may not work for WPA2 enterprise; for WEP hex keys see the last example here. You will also need the password for the WiFi network. For most home routers this is located on a sticker on the back of the router. The ESSID (ssid) for the network in this case is testing and the password (psk) testingPassword .

Adding Network Details to Raspberry Pi

First you’ll need to ammend /etc/network/interfaces to point to wpa-supplicant if it isn’t already:

We’ve changed it to wpa-roam so that it will reconnect if the connection drops.

Open the wpa-supplicant configuration file in nano:

sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

Go to the bottom of the file and add the following:

The following are different ways of configuring your network depending on what encryption your router is configured to.

WPA/WPA2

Open Network

Hidden SSID

Now save the file by pressing ctrl+x then y, then finally press enter.

At this point, wpa-supplicant will normally notice a change has occurred within a few seconds, and it will try and connect to the network. If it does not, either manually restart the interface with sudo ifdown wlan0 and sudo ifup wlan0 , or reboot your Raspberry Pi with sudo reboot .

You can verify if it has successfully connected using ifconfig wlan0 . If the inet addr field has an address beside it, the Pi has connected to the network. If not, check your password and ESSID are correct.

WICD-Curses

Note that this may cause a small amount of background cpu usage, which can stop the CPU from scaling to lowest frequency.

you first need to install it with sudo apt install wicd wicd-curses and then type wicd-curses in the terminal to open it.

(of course you’ll need to be connected by ethernet to install it)

How to setup wi-fi on your raspberry pi via the command line

Navigate to your wireless network and Press the RIGHT arrow to configure your wifi

How to setup wi-fi on your raspberry pi via the command line

check automatically connect to this network (by pressing enter) and type in your wifi password where it says “key” press F10 to save and then press SHIFT+c to connect and press Q to exit back to the terminal.

There are some noted issues with the daemon using some CPU and preventing the Pi from scaling to lowest frequency, so if that’s the case you can remove wicd-curses by typing sudo apt remove wicd-curses and proceed to setup your wifi using method 2 or 3.

You may want to use an external Wifi dongle: maybe your pi case is blocking or slowing the signal (with a metal case it’s pretty common), for instance.

How to setup wi-fi on your raspberry pi via the command line

Setting up a proper WiFi connection on Raspberry Pi is somewhat tricky for beginners. They often face some issues while trying to connect Raspberry Pi to WiFi. One of the main questions I’m receiving from the newbies is Raspberry Pi is not connecting to WiFi, what should I do?

And some others are asking to give a proper Raspberry Pi WiFi setup that they can follow easily. Since I’m getting questions like this regularly, I decided to write a detailed guide to set up a WiFi connection on the Raspberry Pi.

Here I’m gonna hold your hands and walk you through 5 different ways by which you can set up a WiFi connection on Raspberry Pi OS or Raspbian. Note that this is not for any specific Raspberry Pi models (but for Raspbian only) so this will work on all models that support WiFi connectivity.

Raspberry Pi WiFi Setup in Headless Mode

Method 1: Using wpa_supplicant File

Here we going headless mode means we are not gonna use or need a monitor/ display connected to your Pi. This method is applicable if you have just flashed your SD card and want to connect it with WiFi in its first boot. However, it also works with an older sd card that you used on any other wireless network.

All you need to do here is to create a raspberry pi wifi setup wpa_supplicant file and copy it to your SD card. Nothing else. This file will hold the WiFi credentials and tell the Pi to connect automatically at the next booting.

  • First, you need to open a text editor (like Notepad) on your computer and copy the following code into it.
  • Now replace YOURSSID and YOURPASSWORD with your WiFi network name and password respectively. The SSID is nothing but Service Set IDentifier and is your network’s name. Also, change the country code if needed.
  • Save the file with the name: wpa_supplicant.conf (the file name should be exactly like this).
  • Insert your SD card into your computer and copy the wpa_supplicant.conf file into the boot partition.

In case if you want to enable SSH automatically, then you need to create and copy another file named ssh into the same boot partition. You don’t actually need any content in that file. Just create an empty file and you’re done.

Set up WiFi on Raspbian Desktop

Method 2: Configure WiFi using Welcome Wizard

For this method of WiFi configuration on your Pi, we need a desktop connection so that we can directly set it up from the welcome wizard.

If this is your first boot after flashing the SD card, then you will surely come across a welcome wizard with a message like “Welcome to Raspberry Pi”. Subsequently, it will ask for setting up your system.

After booting, once you choose your language and country, you will be taken to a window like this:

How to setup wi-fi on your raspberry pi via the command line

Here select your WiFi network name (SSID) from the list and enter the password. That’s all. Wait for a few moments and you’ll be connected to the network.

Method 3: Connecting from the Taskbar

Just in case you missed the welcome wizard or this is not your first boot, you can configure and connect at any time from the taskbar. For this:

  • Click on the network symbol at the top of the main panel near the clock.
  • You will now see a list of WiFi networks available.
  • Choose your preferred network, enter the password.

That’s it. Simple 🙂

Set up WiFi on Raspbian Lite

If you are running on the Raspbian Lite version, then you may need some additional help you find out and configure the WiFi properly. On Raspbian Lite, there are 2 methods by which you can do the same. Let’s check it out.

Method 4: Using raspi-config Tool

The raspi-config is a great tool available on Raspbian by default. This will help you configure your wireless network with ease.

  • Open the terminal and run the command:
  • You will see a screen like this:

How to setup wi-fi on your raspberry pi via the command line

  • Navigate to the Network Options > Wi-Fi
  • Then type your SSID and password.
  • Exit the tool.

Your Pi will now connect to the WiFi network and you can proceed with that.

Method 5: Manual Configuration

This method is a bit difficult but may be useful for connecting to big networks that need secure authentication or other complexities.

For manual configuration, the first part is the same as we did in method 1 that is editing the wpa_supplicant.conf file with your desired configuration. The file will be available at /etc/wpa_supplicant/ and you can edit it using the Nano editor. For this, you can use this command:

This will open the file and you can see the same content as we have seen in method 1. That’s actually a basic configuration.

If you are interested, you can refer to some more examples here to adapt the configurations to your network for security options like WEP, EAP, etc.

Now, when coming to the network configuration, if you wish to set a static IP on your network, the configuration can be performed in dhcpcd.conf file. Type this command to open the file:

Now scroll down and find the “Example static IP configuration” line and uncomment every line of code that you need. This may include routers, DNS, IP address, etc. Modify the values and save them.

To reflect the changes, just reboot your Pi using the below command.

Final Words

Hopefully, by now you have familiarised all the 5 methods that can be used for Raspberry Pi WiFi setup. Now you can try this yourself and configure your WiFi according to your needs.

Wherever possible, try to use the desktop methods which will be the easiest ones for beginners. For advanced users, they can use any of the methods at any time. But before proceeding with complicated experimentation or modification, consider creating a backup of your sd card. This will be useful at times when you mess up with something.

If you have any comments, drop them in the comment section below.

Found an issue with this article? Report it here, so that I can resolve it.

Follow MUO

Unlike older models, the Raspberry Pi 3 and 4 have Wi-Fi and Bluetooth capabilities. Here’s how to set them up properly.

Most Raspberry Pi models now ship with on-board connectivity options. The Raspberry Pi 3, 3B+, Raspberry Pi Zero W, and Raspberry Pi 4 all feature built-in Bluetooth and Wi-Fi.

This inclusion extends the possibilities for your projects, saving you from relying on USB dongles and hubs. But just how do you set up Wi-Fi on a Raspberry Pi 3 or later? How does Bluetooth connect?

Here’s what you need to know about setting up wireless networking via Wi-Fi and Bluetooth on Raspberry Pi.

Wi-Fi and Bluetooth on the Raspberry Pi 3 and 4

The Raspberry Pi 3 is the first version of the computer to have on-board wireless and Bluetooth. Subsequent version with these features include the Raspberry Pi Zero W, the Raspberry Pi 3 B+, and the Raspberry Pi 4.

With Wi-Fi built-in, the Raspberry Pi can be easily connected to wireless networks. This enhances connectivity considerably. Meanwhile, including a Bluetooth radio on the Raspberry Pi (the Pi 3 has Bluetooth 4.1 BLE, the Pi 3 B+ 4.2 BLE, and the Pi 4 Bluetooth 5.0) means you can add any device, such as a smartphone, a TV, or an Xbox One controller

Set Up Wi-Fi on the Raspberry Pi via Desktop PC

The easiest way to connect your Raspberry Pi to a wireless network is to use the desktop tool. However, this means that you will need to set it up with a keyboard, mouse, and display. The alternative is to first hook up an Ethernet cable, then connect via VNC or RDP. Just remember to disconnect Ethernet when the Pi is connected wirelessly!

To connect to your router, right-click the grayed-out wireless networking icon in the right corner of the panel. Select the option to Turn on Wi-Fi, then select the desired network from the menu.

Input the Pre Shared Key when prompted, then wait for the connection to be established.

You should now be online.

Configure Wireless Networking to Connect the Raspberry Pi to Wi-Fi

Alternatively, you can set up wireless networking in the command line. This is a good option if you’re accessing your Raspberry Pi using SSH (initially over Ethernet).

You have two options for setting up a wireless connection. It might seem easier to boot into the GUI, but it’s more straightforward to do it in the command line. You should already have your SSID name, but if not, use

This will reveal the SSID in the line “ESSID”. Next, open wpa_supplicant.conf:

You’ll need to add or edit the following:

Take the time to change the value for country as appropriate and add the SSID and password for your network.

Use Ctrl + X to exit and save, pressing Y and Enter to confirm. Wireless connectivity should start immediately. If not, use this command to restart wireless:

You could also simply enter

Set Up Wi-Fi on Raspberry Pi 3 Before Booting

Another option for Wi-Fi on the Raspberry Pi 3 and later is to configure it before the first boot. This is possible by inserting the microSD card in your PC’s card reader and browsing to the /boot/ directory. Here, create a text file called wpa_supplicant.conf then open it and add the details as you did above.

Save this, close the file, then safely eject the microSD card. Note that the success of this method will depend on your Raspberry Pi operating system. It works with pre-Raspbian Buster OSs, as well as various other operating systems. Raspbian Buster has a Wi-Fi driver that prevents the use of a wpa_supplicant.conf file in this way.

Configure Bluetooth on the Raspberry Pi 3 and 4

As with Wi-Fi, the software to configure and connect Bluetooth is built into Raspbian Buster. For older versions, run update and upgrade, then

You can now activate Bluetooth from the command line with:

A host of options are available with this. Type “help” to see them.

For Bluetooth to work, it needs to be enabled, discoverable and capable of discovering devices.

We use three commands to do this:

In this screen, you can see the Raspberry Pi has detected my Ubuntu phone. A connection can be made by entering connect, followed by the MAC address. If a passcode is required on the remote device, enter this when prompted.

Moments later, your Bluetooth connection will be established.

Connect to Bluetooth on the Raspberry Pi Desktop

If you prefer to setup your Raspberry Pi Bluetooth connections on the desktop, click the Bluetooth icon in the panel. In the menu, select Add Device to find discoverable devices, select the one you want, then Pair to begin the pairing/trust process.

Bluetooth is up and running!

Connect an Older Raspberry Pi to Wi-Fi and Bluetooth

If you own a Raspberry Pi 2 or earlier, or a standard Raspberry Pi Zero, Wi-Fi is not an option. Indeed, in the case of the Raspberry Pi Zero, Ethernet is not an option either. The solution is USB dongles that add Wi-Fi and Bluetooth capability to the Pi.

Top USB Wi-Fi Dongle for Raspberry Pi

Need to connect your older Raspberry Pi to a wireless network? You’ll need a USB Wi-Fi dongle, but with limited USB ports on the original models, this can be frustrating. Ethernet might be preferable.

Get a USB Bluetooth Dongle for Raspberry Pi

USB Bluetooth dongles are also available for the Raspberry Pi. However, you may find that you won’t enjoy the functionality from a dongle that can be enjoyed with integrated Bluetooth

For Raspberry Pi Zero-based projects requiring Wi-Fi and Bluetooth, you have two options. The first is to switch to a Raspberry Pi Zero W, which is incredible value for a computer.

Otherwise, you’ll need to connect standard USB dongles to your Pi Zero using a USB hub with a micro-USB cable. The dongles above will work on the Pi Zero with this USB hub.

Wi-Fi on the Raspberry Pi 3 and 4 Is Enabled!

You should now be up and running with wireless and Bluetooth on the Raspberry Pi 3 and 4. As with any computer, it is straightforward to set up; with some operating systems, you can configure it before booting.

Meanwhile, Bluetooth is just as simple, and allows remote controls to be connected, as well as audio devices. The hardware is reliable and the software uncomplicated. And if you’re using an older Raspberry Pi, these features are also available via USB dongles.

We hope you like the items we recommend and discuss! MUO has affiliate and sponsored partnerships, so we receive a share of the revenue from some of your purchases. This won’t affect the price you pay and helps us offer the best product recommendations.

There are lots of different caches in Windows 11, and each one can take up quite a bit of space. As such, a spring clean is sometimes needed.

How to setup wi-fi on your raspberry pi via the command line

Deputy Editor for Security, Linux, DIY, Programming, and Tech Explained, and Really Useful Podcast producer, with extensive experience in desktop and software support. A contributor to Linux Format magazine, Christian is a Raspberry Pi tinkerer, Lego lover and retro gaming fan.

Subscribe to our newsletter

Join our newsletter for tech tips, reviews, free ebooks, and exclusive deals!

In this tutorial you will learn how to connect to WiFi from command line using Netplan. This could be useful if you are running a headless Ubuntu 20.04 system such as server or Ubuntu 20.04 on Raspberry Pi.

In this tutorial you will learn:

  • How to identify the name of your wireless network interface
  • How to configure Netplan to connect to wireless network (SSID)

How to setup wi-fi on your raspberry pi via the command line

Software Requirements and Conventions Used

Software Requirements and Linux Command Line Conventions

Category Requirements, Conventions or Software Version Used
System Installed Ubuntu 20.04 or upgraded Ubuntu 20.04 Focal Fossa
Software N/A
Other Privileged access to your Linux system as root or via the sudo command.
Conventions # – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ – requires given linux commands to be executed as a regular non-privileged user

Ubuntu 20.04: Connect to WiFi from command line with Netplan step by step instructions

  1. First step is to identify the name of your wireless network interface. To do so execute:

Depending on your Ubuntu 20.04 system the wireless network interface name would be something like: wlan0 or like in this case it is wlp3s0 .
Next, navigate to the /etc/netplan directory and locate the appropriate Netplan configuration files. The configuration file might have a name such as 01-network-manager-all.yaml or 50-cloud-init.yaml .

and insert the following configuration stanza while replacing the SSID-NAME-HERE and PASSWORD-HERE with your SSID network name and password:

Make sure that the wifis block is aligned with the above ethernets or version block if present. The entire configuration file may look similar to the one below:

Alternatively, you may also wish to configure a static IP address to your wireless interface.
Once ready, apply the changes and connect to your wireless interface by executing the bellow command:

Alternatively, if you run into some issues execute:

  • If all went well you would be able to see your wireless adapter connected to the wireless network by executing the ip command:
  • How to setup wi-fi on your raspberry pi via the command line

    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.

    To view this video please enable JavaScript, and consider upgrading to a web browser that supports HTML5 video

    1. Connecting Raspberry Pi to Wi-Fi command line
    2. Final Word

    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.

    How to setup wi-fi on your raspberry pi via the command line

    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.

    How to setup wi-fi on your raspberry pi via the command line

    The Raspberry Pi 3 Microcontroller is a very powerful mini computer and one of the most important features is that it incorporates a Wifi chip and can connect to a wireless network. It is the first step to access the potential of the Raspberry Pi and the first step towards the development of a home automation server, a connected object or a robot.

    Equipment

    • Screen
    • HDMI cable
    • Keyboard
    • Raspberry PI 3
    • Micro SD card
    • Mouse
    • Micro USB charger B

    Connect the Raspberry Pi to WiFi using the desktop

    Once the Raspbian OS is installed you can connect the microcontroller to WiFi as on a PC via the desktop. All you need to do is activate Wifi in the task bar at the top right of the screen, select the network name (SSID) and enter the network key (WPA-PSK).

    In some cases, it may be interesting to know how to connect WiFi via command lines on the terminal. This is what we will see here.

    Connect the Raspberry Pi to WiFi using the terminal

    Open the control terminal with the icon at the top left of the screen (or Ctrl + Alt + t). We will modify the configuration file wpa_supplicant.conf using the “sudo nano” function.

    Once the file is open, edit the following lines at the bottom of the file.

    • For a WPA/WPA2 key
    • For a WEP key
    • For an open network

    You can then enter the following command lines to activate the WiFi chip

    or (it may not work on some version)

    You can then restart your Raspberry using the command

    Your Raspberry should automatically connect to WiFi the next time you start it.

    Next steps

    How useful was this post?

    Click on a star to rate it!

    Average rating 0 / 5. Vote count: 0

    No votes so far! Be the first to rate this post.

    As you found this post useful.

    Follow us on social media!

    We are sorry that this post was not useful for you!

    I first installed Raspberry pi OS with Desktop and recommended software for my raspberry pi zero w, system

    Although it took a long time, it can indeed be started normally, but unfortunately open a chrome browser to open a webpage and save the poor 512M

    I ran out of memory and couldn’t open the webpage even after waiting for 10 minutes. Although in theory low-configuration devices like raspberry pi zero can also be used on the desktop

    System, but the practicability is very poor, the second best thing is to reinstall a Raspberry Pi OS Lite(Raspberry pi install and burn the operating system).

    If you install Raspberry Pi OS Lite, there will be no graphical desktop system, then the question is how to install Raspberry Pi (Raspberry Pi)

    How to configure wifi under the command line? In fact, Raspberry Pi OS Lite has prepared a very useful configuration tool for everyone: raspi-config.

    How to setup wi-fi on your raspberry pi via the command line

    first step

    Enter sudo raspi-config in the command line, and press Enter.

    Second step

    The following screen will pop up to enter the raspi-config interface, use the keyboard up and down arrow keys to move the red box to 2 Network Options, and press Enter.

    How to setup wi-fi on your raspberry pi via the command line

    third step

    Use the keyboard up and down arrow keys to move the red box to N2 Wireless LAN, and press Enter.

    the fourth step

    Use the keyboard up and down arrow keys (or the mouse to pull the scroll bar on the left), move the red box to CN China, and press Enter.

    How to setup wi-fi on your raspberry pi via the command line

    the fifth step

    The pop-up prompt box prompts to set the wireless network area to China, press Enter to confirm.

    How to setup wi-fi on your raspberry pi via the command line

    Sixth step

    In the pop-up dialog box, enter your WIFI SSID, that is, the name of the WIFI network, and press Enter to confirm.

    How to setup wi-fi on your raspberry pi via the command line

    Seventh step

    Enter the wifi password in the pop-up dialog box, and then press the Enter key to continue, if there is no password, press the Enter key directly.

    How to setup wi-fi on your raspberry pi via the command line

    Eighth step

    Press Tab to move the red box to Finish, press Enter, raspi-config will exit automatically and return to the command line.

    How to setup wi-fi on your raspberry pi via the command line

    Step 9

    Restart raspberry pi zero w, and then use the command ifconfig to confirm whether the configuration is successful, if you see wlan0: in this item, there is already inet: 192.168.xx.xx

    Such words indicate that the wifi configuration is successful and your raspberry pi can connect to the network.

    How to setup wi-fi on your raspberry pi via the command line

    If this article is helpful to you, don’t forget to like or bookmark it

    How to setup wi-fi on your raspberry pi via the command line

    Connect Raspberry Pi to WIFI

    material: A Raspberry Pi 3B+ (with WIFI module, some previous versions did not have WIFI module), a host, and a wireless router 1. Turn on the Raspberry Pi 2. Enter the command Add configuration infor.

    Raspberry Pi behalf of the brush 3 solution ubuntu mate configuration bug not a strange wifi connection at the command line

    Home router is not in his bedroom, with a raspberry pie consider the use of wifi, with Raspberry before the official system, follow the tutorial written wpa.conf can connect wifi, then re-brush ubuntu.

    How to setup wi-fi on your raspberry pi via the command line

    How to configure WiFi for a new Raspberry Pi without a screen and keyboard, and remotely control it via command line or desktop

    Preface and introduction I recently started with Raspberry Pi 4B. I have no extra HDMI interface monitor and keyboard. It is very inconvenient to control the Raspberry Pi. After researching and referr.

    How to setup wi-fi on your raspberry pi via the command line

    Configure Raspberry Pi to connect to WiFi

    inConnecting network cable(See the previous section.) In the case of success, let’s configure the Raspberry Pi to connect to WiFi. 1. Edit the interface file Log in to the Raspberry Pi via putty or xs.

    Raspberry Pi 3B – Connect wifi

    The following is a method of connecting wifi (WPA/WPA2) to the terminal without a display. Method one raspi-config Run as rootraspi-configI believe you will use it soon. Method Two View the surroundin.

    • Forums
    • SingleBoard Computers
    • Raspberry Pi
    • Tutorials

    unknown

    visitor
    • Apr 5, 2021
  • #1
  • sooo i had this little issue that i wanted to connect my rapsberry pi kali linux projets to the wifi.
    As the /etc/wpa_supplicant/wpa_supplicant.conf is working for normal raspberry pi’s does this not work with the kali’s

    so here is a fast way to connect your project to the wifi

    STEP #1
    Open and edit your interfaces file with nano

    STEP #2
    now we add the following lines:

    Replace WiFiname with your own wifi name
    Replace WiFikey with your own wifi password

    STEP #3
    Now we reboot our device

    Similar threads

    • unknown
    • Apr 5, 2021
    • Tutorials
    • unknown
    • May 30, 2021
    • Tutorials
    • unknown
    • May 9, 2021
    • Tutorials
    • unknown
    • Apr 5, 2021
    • Tutorials
    • unknown
    • Apr 4, 2021
    • Tutorials
    • Forums
    • SingleBoard Computers
    • Raspberry Pi
    • Tutorials

    Our community has been around for many years and pride ourselves on offering unbiased, critical discussion among people of all different backgrounds. We are working every day to make sure our community is one of the best.

    Connect to the internet with your Raspberry Pi

    How to setup wi-fi on your raspberry pi via the command line

    • Saint Mary-of-the-Woods College
    • Tweet
    • Share
    • Email

    For every version of Raspberry Pi prior to the latest Pi 3, connecting to the internet was achieved in one of two ways. You could connect using an Ethernet port or a USB Wi-Fi adapter.

    Here’s how to set up a USB Wi-Fi adapter with your Pi, using an Edimax EW-7811Un as the example.

    Connect Hardware

    To connect the Raspberry Pi hardware components, turn off the Raspberry Pi and fit the Wi-Fi adapter into any of the Pi’s available USB ports. It doesn’t matter which port you use. Next, connect the keyboard and screen if you haven’t done so already. When that’s done, turn on the Raspberry Pi and give it a minute to boot up.

    Open the Terminal

    If your Pi boots to the terminal by default, skip this step.

    How to setup wi-fi on your raspberry pi via the command line

    If your Pi boots to the Raspberry Pi OS desktop (LXDE), select the Terminal icon in the taskbar. It looks like a monitor with a black screen.

    Edit the Network Interfaces File

    The first change to make is to add a few lines to the network interfaces file. This sets up the USB adapter to be used, and later on, you’ll tell it what to connect to.

    In the terminal, type in the following command and press Enter:

    The file will have some lines of text in it, which can be different depending on the Raspberry Pi OS version. Regardless, make sure you have the following four lines—some may be there:

    How to setup wi-fi on your raspberry pi via the command line

    Press Ctrl+X to exit and save the file. You’re asked if you want to save the modified buffer. In other words, you are prompted to save the file. Press Y and then press Enter to save the file under the same name.

    Edit the WPA Supplicant File

    The supplicant file is where you tell the Pi which network to connect to and the password for that network.

    Before you edit the wpa_supplicant configuration, encrypt your network password and send it to the file. You can do this with the wpa_passphrase command.

    How to setup wi-fi on your raspberry pi via the command line

    Give the command the name of your network (SSID) and your password. Then, direct the output to the wpa_supplicant file. It looks something like this:

    In the terminal, type the following command, and press Enter:

    If the Pi is connected to a Wi-Fi network, you may see two network blocks. If not, you’ll only have the one you created with wpa_passphrase. The one you created has psk equal to a long string of characters, and the plain text password is commented out. Delete the plain text password line.

    Delete any previous network blocks to ensure that the Pi connects to the right one.

    How to setup wi-fi on your raspberry pi via the command line

    Inside the network block with the encrypted psk, add the following lines below the psk to tell the Pi how to connect to the wireless network.

    How to setup wi-fi on your raspberry pi via the command line

    With that set up, save and exit the file. Press Ctrl+X, Y, then press Enter.

    Optional Step: Turn Off Power Management

    If you experience issues with the Wi-Fi adapter dropping connections or becoming unresponsive, the driver’s power management setting may be the cause of the problem.

    To turn off power management, create a new file with a line of text inside it. Enter the following command to create this new file:

    Then enter the following line of text:

    Press Ctrl+X to exit the file, then save the file under the same name.

    Reboot Your Raspberry Pi

    That’s everything you need to do to set up a Wi-Fi adapter. Next, reboot the Pi to put all of these changes into effect.

    Type the following command in the terminal to reboot, then press Enter:

    The Pi should restart and connect to the network within a minute or so.

    Troubleshooting

    If your Pi doesn’t connect, there are a few things you should check:

    In this post, you’ll configure the WiFi on your Raspberry Pi. If it’s your first time using the RPi, first make sure you read my Getting Started with Raspberry Pi guide.

    Setting up your WiFi via the command line is the best method, since you don’t necessary need access to the GUI (Graphical User Interface) everything you need is already right there (in your command line).

    1) Accessing Your Command Line

    Boot your Raspberry pi with the WiFi adapter plugged in. You can access your command line using one of the following methods:

    • Having an Ethernet connection ensures that you can open an SSH client like PuTTY to establish an SSH communication
    • Using the Raspberry Pi GUI to open your terminal window

    How to setup wi-fi on your raspberry pi via the command line

    2) Checking if your RPi recognizes your WiFi adapter

    There are several ways to check if your WiFi adapter has been recognized. You can type:

    And your wireless adapter named as wlan0 should appear as shown in the Figure below.

    How to setup wi-fi on your raspberry pi via the command line

    If you don’t see your WiFi adapter listed, you might have to install drivers for your particular WiFi adapter. I’m using the TL-WN725N and by default Raspbian doesn’t support my WiFi adapter. So I’ve followed this thread to install my drivers.

    If you don’t have a WiFi adapter yet, I highly recommend purchasing the Edimax EW 7811UN. This is a good option, because Raspbian comes with its drivers installed out of the box, that ensures that your RPi recognizes that WiFi adapter.

    How to setup wi-fi on your raspberry pi via the command line

    3) Opening configuration file

    Type the following command to open your configuration file:

    How to setup wi-fi on your raspberry pi via the command line

    4) Adding your network details

    Go to the bottom of your configuration file wpa_supplicant.conf and add your network details as shown below. Replace “YOUR-SSID” and “YOUR-SSID-PASSWORD” with the details of your WiFi connection.

    How to setup wi-fi on your raspberry pi via the command line

    Now save your file by pressing Ctrl+x then y, then finally press Enter.

    5) Testing your connection

    You can check the status of the wireless connection using ifconfig (to see if wlan0 has acquired an IP address) and iwconfig to check which network the wireless adapter is using.

    How to setup wi-fi on your raspberry pi via the command line

    Do you have any questions? Leave a comment down below!

    Thanks for reading. If you like this post probably you might like my next ones, so please support me by subscribing my blog and my Facebook Page.

    This involves connecting your Raspberry Pi wirelessly using WiFi through your WiFi modem. The computer can be connected to the modem using wireless as well, or using an Ethernet cable.

    Telling your Raspberry Pi your WiFi network name and password

    Before you can connect wirelessly to you Pi you’ll first need to do some configuration on the Pi. You need to put your WiFi network name and your WiFi password in a configuration file.

    If you have a keyboard, mouse and HDMI monitor directly connected to your Pi then that’s easy. Just log into your Pi and do the steps below. When you log into the Pi you’ll be asked for a username and a password. The default username is pi and the default password is raspberry (you won’t see the password as you type it).

    If you don’t have a keyboard and display attached to your Pi then you’ll have to connect to the Pi using an Ethernet cable and log into your Pi. Two methods for doing that are detailed at the two links below. Choose whichever you want:

    In either case, whether using a keyboard and display connected directly to your Pi or using one of the two methods detailed at the two links above, you should now be logged into your Pi.

    To tell the Pi your WiFi network name and password you’ll need to edit a file called /etc/wpa_supplicant/wpa_supplicant.conf .

    1. On the Raspberry Pi, go to /etc/wpa_supplicant. Since I was doing this from a command line terminal, I did:

    2. Edit the file that you’ll find there called wpa_supplicant.conf . To do that I first used the “ls” command to verify that it was there and then I used the editor called nano as follows:

    3. In the wpa_supplicant.conf file, go to the bottom and add what’s shown in the example below but put your own WiFi network name in place of “BOB” and your own WiFi password in place of “orange”. To make sure it’s clear, here it is in plain text:

    4. Save the file by pressing Ctrl-O and exit the editor by pressing Ctrl-X.

    5. Restart the Pi. Make sure to use the shutdown command first to give the editor and anything else time to write to the SD card.

    Connecting to WiFi

    Once you’ve told the Pi the WiFi information as detailed in the steps above, it’s time to try it out.

    I have the Raspberry Pi 3 Model B which has WiFi built in. If you have a Pi that doesn’t then you’ll need a WiFi dongle as shown below. Plug that into any of the USB ports of your Pi.

    Next, give power to your Raspberry Pi. You should see various lights lit up at different times.

    Finding the Pi’s IP address

    After a minute or so the Raspberry Pi should have connected to your WiFi. To start talking to it from your computer, you need to find out its IP address.

    One way to do that is to bring up a web browser on your computer and go to your WiFi modem’s webpage, most modems have one. Type in the IP address of your modem to connect to it as is shown in the snapshot below. Type the address into the browser’s address bar, located near the top-left of the browser window, and press Enter. If you don’t know the modem’s IP address then contact your internet provider to get it. It’ll be something like 192.168.1.1 or 192.168.2.1. In the snapshot I’m using the Firefox browser running on Windows Vista and have already given it the IP address following the above steps. You can see it circled in the top, left. Note that I typed in only the “192.168.2.1” in the address bar. The browser filled in the stuff that you see following it. My modem is called the Bell Home Hub 1000 and that’s what you see in the webpage that came up. Unless you have the same modem, yours will look different but have similar features.

    In the Network section of the webpage I found a diagram of what’s connected to the modem. Circled in red at the bottom, you can see that it’s showing the Raspberry Pi as being connected and it’s giving its IP address, 192.168.2.15, the one we’re looking for.

    Using the IP address to connect to the Pi

    Now that you have the Pi’s IP address, you can connect to it however you want, provided the setup on your Pi allows you to connect.

    In my case, the setup that came with Raspbian on my SD card allowed me to ping the Pi to see if I could get to it at all. This is done by running the ping command and passing it the Pi’s IP address, as shown below. Doing a ping is like tapping it on the shoulder to see if it’s there.

    I could also start up an SSH (secure shell) session using PuTTY, free software that most Pi users use at one point or another. In the snapshot below I’m running it from a Windows Command Prompt window. Once it was up, I typed in the Pi’s IP address.

    Note above that the Connection type is selected as SSH and so when I click on the Open button I get a new window with an SSH running in it. I’m asked to log in. For a new Raspberry Pi system the username is usually pi and the password is raspberry.

    At this point you are connected and able to start typing commands.

  • Play
  • Contact
    • About
    • Work
    • Play
    • Contact

    A big part of Raspberry Pi’s usefulness comes from its size. A lot of those benefits get lost when you need an external display and keyboard (and mouse maybe) to actually do anything with it. In this post I’ll quickly cover how you can set up your Raspberry Pi (A, but B would work too, it’d actually be a little bit easier) to automatically connect to your wireless network and obtain a static IP. All you need is a WiFi-dongle.

    Because the Raspberry Pi A only has one USB-port, there’ll be a lot of USB switching.

    Setting up WiFi connection

    Start by booting the Raspberry Pi, connected to a display and a keyboard. Open up the terminal and edit the network interfaces file:

    $ sudo nano /etc/network/interfaces

    This file contains all known network interfaces, it’ll probably have a line or two in there already.

    Change the first line (or add it if it’s not there) to:

    Then at the bottom of the file, add these lines telling the Raspberry Pi to allow wlan as a network connection method and use the /etc/wpa_supplicant/wpa_supplicant.conf as your configuration file.

    (ctrl-X, then type Y to quit and save)

    The next step is to create this configuration file.

    Configuring WiFi connection

    Open up the wpa_supplicant.conf file in the editor.

    $ sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

    Again, some lines might already be present, just add the following.

    The other parameters are network specific, I can’t tell you what you need. If you boot Raspbian to desktop, you can launc the wpa_gui (WiFi config) application and click ‘Scan’. You’ll find a list that has your network too with all flags you need. To do this on a RPi A you’ll have to disconnect your keyboard and connect your dongle once the scanning list is open.

    • proto could be either RSN (WPA2) or WPA (WPA1).
    • key_mgmt could be either WPA-PSK (most probably) or WPA-EAP (enterprise networks)
    • pairwise could be either CCMP (WPA2) or TKIP (WPA1)
    • auth_alg is most probably OPEN , other options are LEAP and SHARED

    Make sure it works

    Reboot the Raspberry Pi and it should connect to the wireless network. If it doesn’t, repeat above steps or get help from an adult.

    A static IP

    Since the goal of this tutorial is to be able to work with the RPi without external keyboard or display, you want to be ssh into it. The best way is to make sure it’ll always have a static IP on your network.

    Doing so is simple. Open the /etc/network/interfaces file again and add the following changes:

    Change iface wlan0 inet dhcp into iface wlan0 inet static . This changes the wlan0 interface from DHCP to static.

    Add the following lines before the wpa-conf line:

    The Raspberry Pi will still be able to connect to the internet.

    Wrapping up

    With these changes you’ll be able to always connect to your Raspberry Pi over your wireless network via ssh at the same, static IP. This means you can disconnect keyboard, mouse and display and have it plugged in a wall socket, anywhere, taking almost no space.

    As an overview, my interfaces- and wpa_supplicant-files: