7

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?
    – oh.dae.su
    Jul 25, 2018 at 17:26
  • yes raspbian stretch
    – fmeier
    Jul 27, 2018 at 12:52
  • If you edited /etc/network/interfaces manually, NetworkManager stops to manage the interface
    – ingroxd
    Jul 27, 2018 at 16:08

2 Answers 2

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.

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?
    – fmeier
    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.
    – oh.dae.su
    Jul 29, 2018 at 7:26
2

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .