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.