9

I could connect to my router using the network manager gui on my raspberry pi without any problems. But when I try to do this using nmcli the wifi connection is unavailable (before I connected using the gui and after that). also when I start nmtui there isn't a wifi connecction. when I run nmcli dev status the output is:

wlan0  wifi      unavailable  --     

What is wrong here? I think its easier to do this using the command line.

3
  • What distribution are you using? Raspbian? Commented Jul 25, 2018 at 17:26
  • yes raspbian stretch Commented Jul 27, 2018 at 12:52
  • If you edited /etc/network/interfaces manually, NetworkManager stops to manage the interface Commented Jul 27, 2018 at 16:08

2 Answers 2

5

In Raspbian, the wireless connections are normally managed by wpa_supplicant (also the GUI). Simply installing network-manager to use it is not enough as layed out in this answer, which gives you directions how to make network-manager run on Raspbian.

If you don't insist on using network-manager, give the command line tool wpa_cli of wpa_supplicant a try.

Here is how you connect to a network with wpa_cli in interactive mode (replace wlan0 with the name of your wireless interface, AP_NAME with the name of your AP, passphrase with the passphrase of the AP and 0 with the number that is printed to stdout after ADD_NETWORK):

sudo wpa_cli -i wlan0

> ADD_NETWORK
> SET_NETWORK 0 ssid "AP_NAME"
> SET_NETWORK 0 psk "passphrase"
> ENABLE_NETWORK 0
> quit

If you don't want to use interactive mode, you simply need to state the command following the options. See a few examples, here:

If you want to disconnect, use

sudo wpa_cli -i wlan0 DISCONNECT

To list all networks, use

sudo wpa_cli -i wlan0 LIST_NETWORKS

To remove stored network with id=0, use

sudo wpa_cli -i wlan0 REMOVE_NETWORK 0

A list of commands that can be used with wpa_cli can be found e.g. here.

2
  • 1
    works. but when i connect to wlan using the pa_cli interactive mode i can't change anything using the "normal" wpa_cli command line options, right? how can i delete connection or disable it in a simple way? Commented Jul 29, 2018 at 7:00
  • 1
    you can change pretty much everything even outside interactive mode. If you want to disconnect you could use sudo wpa_cli -i wlan0 DISCONNECT. If you read up on the documentation, you can find the different options. I will update my answer shortly. Commented Jul 29, 2018 at 7:26
4

You can see your WiFi device status with

nmcli radio

If the status is "disabled", you can re-enable it; use

nmcli radio wifi on 

Thanks to steeldriver, Leopold Vilnius and Adriano for their answers to How to disable wireless from command line on Ask Ubuntu.

2
  • 1
    Just ran into this on raspberry pi (11 (bullseye)); turns out it was due to the supplicant service not running; it was improperly installed; did an apt-get reinstall wpasupplicant and then did a sudo systemctl unmask wpa_supplicant.service and sudo systemctl enable wpa_supplicant.service and then rebooted - the gui show shows the local networks to connect to (and it works) and the nmcli shows the usb networks adapter as connnected; real puzzler and I hope it helps out someone else Commented Mar 13, 2024 at 17:24
  • Also encountered this issue (rpi + bullseye + omv) and your solution @MarkZ.Kumler finally fix it!!! I cannot thank you enough :) Commented Jan 2 at 19:55

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.