Find and connect to WiFi networks from the command line with nmcli
Run:
$ nmcli device wifi
to list available Wifi access points.
You should see something like this:
IN-USE BSSID SSID MODE CHAN RATE SIGNAL BARS SECURITY
A2:C9:EB:E7:DB:B8 Wifi_name Infra 3 270 Mbit/s 100 ▂▄▆█ WPA2
9C:C9:EB:E7:DB:B8 -- Infra 3 130 Mbit/s 100 ▂▄▆█ WPA2
9C:C9:EB:32:41:DD -- Infra 3 270 Mbit/s 85 ▂▄▆█ WPA2
A2:C9:EB:32:41:DD Wifi_name Infra 3 270 Mbit/s 82 ▂▄▆█ WPA2
A2:C9:EB:E9:92:87 Wifi_name Infra 3 270 Mbit/s 75 ▂▄▆_ WPA2
9C:C9:EB:E9:92:87 -- Infra 3 270 Mbit/s 70 ▂▄▆_ WPA2
A2:C9:EB:E9:88:49 Wifi_name Infra 3 270 Mbit/s 29 ▂___ WPA2
9C:C9:EB:E9:88:49 -- Infra 3 130 Mbit/s 25 ▂___ WPA2
Then pick the BSSID of the access point you want to connect to e.g. A2:C9:EB:E7:DB:B8
, and run:
$ nmcli device wifi connect A2:C9:EB:E7:DB:B8 password [password]
If the connection to the access point was successful, you should see:
Device 'wlp2s0' successfully activated with 'redacted_address'.
To test the connection was established, you can run:
$ ping yctct.com
See man nmcli
to learn more about nmcli
.
Issues
- when I connect to a WiFi access point using nmcli, I have to disconnect from the VPN, for the internet connection to establish; then I can reconnect to the VPN
sometimes, nmcli says my laptop is connected to an access point, however, ping yields 100% packet loss; I need to figure why.Solution is to disconnect and reconnect VPN.
Add Aliases
Each time I switch back on the WiFi switch that is on the case of the Thinkpad X220, I have to reconnect to the access point. The command are long; I added two aliases:
alias wifi='nmcli device wifi' # to check that the access point I want to connect to is stared
alias wico='nmcli device wifi connect [stared_SSID]' # to activate a connection with the stared access point (does not need password)
This was tested on a Thinkpad X220 running GNU/Linux Trisquel 11 on osboot.
Note: I found nmcli
with the help of the utility apropos
by running apropos network
.
personal computing command-line interface (cli) gnu linux trisquel shell literacy office applications wiki nmcli