6

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.

GAD3R
  • 63,407
  • 31
  • 131
  • 192
fmeier
  • 199
  • 1
  • 2
  • 9

2 Answers2

4

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.

oh.dae.su
  • 303
  • 1
  • 4
  • 10
  • 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? – fmeier Jul 29 '18 at 07: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. – oh.dae.su Jul 29 '18 at 07:26
1

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.

star_link
  • 11
  • 1