If you want to connect to a network called PrettyFlyForAWiFi-5G
nmcli -a d wifi connect PrettyFlyForAWiFi-5G
-a
(or --ask
) means it will ask you for the password. The connection will be saved and should connect automatically if you restart your computer.
You could append password <your password>
to the end (the literal word password
followed by the actual password)
nmcli d wifi connect PrettyFlyForAWiFi-5G password 12345678
but maybe run unset HISTFILE
beforehand, so that your WiFi password isn't saved to your ~/.bash_history
file.
To see all the WiFi networks around you (--rescan yes
is optional, the list of networks might be up to 30 seconds old without it)
nmcli d wifi list --rescan yes
which will output something like
IN-USE SSID MODE CHAN RATE SIGNAL BARS SECURITY
PrettyFlyForAWiFi-5G Infra 44 405 Mbit/s 59 ▂▄▆_ WPA2
PrettyFlyForAWiFi Infra 6 195 Mbit/s 41 ▂▄__ WPA1 WPA2
To forget a connection (that was saved after you ran nmcli -a d wifi connect <name>
)
nmcli c delete PrettyFlyForAWiFi-5G
To see a list of all saved connections
nmcli c
You can use nmcli connection
instead of nmcli c <whatever>
and nmcli device
instead of nmcli d
nmcli
is the command line interface for NetworkManager (which is part of GNOME, Ubuntu's default desktop environment) and is already installed on Ubuntu.
Don't forget to set up your country code for using the perfect regulations:
sudo iw reg set <2 letter country code>
sudo nano /etc/default/crda