Connect to WiFi Access from command line in ubuntu / Linux without network manager using nmcli

 vim connect_to_wifi.sh 
#!/bin/sh
ACCESS_POINT_SSID=myaccesspoint_name
ACCESS_POINT_PASSWORD=myaccesspoint_password
echo "scanning..."
nmcli d wifi list
echo -n "connecting...."
#nmcli d wifi connect $ACCESS_POINT_SSID password $ACCESS_POINT_PASSWORD iface wlan0
nmcli d wifi connect $ACCESS_POINT_SSID password $ACCESS_POINT_PASSWORD
echo "done"
<<COMMENT
Usage: nmcli [OPTIONS] OBJECT { COMMAND | help }
OPTIONS -t[erse] terse output -p[retty] pretty output -m[ode] tabular|multiline output mode -c[olors] auto|yes|no whether to use colors in output -f[ields] <field1,field2,...>|all|common specify fields to output -e[scape] yes|no escape columns separators in values -a[sk] ask for missing parameters -s[how-secrets] allow displaying passwords -w[ait] <seconds> set timeout waiting for finishing operations -v[ersion] show program version -h[elp] print this help
OBJECT g[eneral] NetworkManager's general status and operations n[etworking] overall networking control r[adio] NetworkManager radio switches c[onnection] NetworkManager's connections d[evice] devices managed by NetworkManager a[gent] NetworkManager secret agent or polkit agent m[onitor] monitor NetworkManager changes
COMMENT

$ bash connect_to_wifi.sh
scanning…
* SSID MODE CHAN RATE SIGNAL BARS SECURITY
myaccesspoint_name Infra 1 54 Mbit/s 62 ▂▄▆_ WPA1 WPA2
— Infra 8 54 Mbit/s 27 ▂___ WPA2
Device ‘wlan0’ successfully activated with ‘some-UUID’.
done

Leave a Reply

Your email address will not be published. Required fields are marked *