Connect raspberry pi 3 to wifi from the command line

April 10, 2020

In my raspberry I installed Debian Stretch Lite, so I could use only the console to connect in my wifi network. Commands wpa_cli and nmcli did not help (wifi was shown unavailable), so I followed these steps.

Make sure your etc/network/inferfaces file to look like as below

sudo nano /etc/network/inferfaces
# interfaces(5) file used by ifup(8) and ifdown(8)

# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'

# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d

auto lo
iface lo inet loopback

iface eth0 inet manual

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

allow-hotplug wlan1
iface wlan1 inet manual
    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

And update etc/wpa_supplicant/wpa_supplicant.conf

sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev


After reboot my raspberry managed to connect