Other posts seems to be addressing more complicated network connection issues from the command line.
The Unity panel Network indicator/button doesn't respond too well sometimes - it keeps trying to connect to a network even when i click on "disconnect", stuff like that.
So I want to go command line for the control. I don't like GUIs anyway.
Is there not some simple command line tool which can do something like the following?
wifi connect MyNetworkNameA
wifi disconnect
wifi connect MyNetworkNameB
I think you want to keep using managed interface (by NetworkManager).
nmcli
is a command‐line tool for controlling NetworkManager.To see list of saved connections, use (
<SavedWiFiConn>
)To see list of available WiFi hotspots (
<WiFiSSID>
)or:
To see list of interfaces (
<WifiInterface>
)Just change
<WifiInterface>
,<WiFiSSID>
,<WiFiPassword>
in the following commands to reflect your setup. If WiFi info already saved, easier way using<SavedWiFiConn>
name of connection as it was saved in NetworkManager.Ubuntu 16.04
Another way:
Ubuntu 15.10 & previous
Another way:
If your password isn't automatically recognized type this:
Reference:
man nmcli
nmtui
ncurses solutionGreat interactive ncurses network manager option:
If for some reason it is not installed, the Debian package is:
Comes in the same package as
nm-applet
(the default top bar icon thing) andnm-cli
, and is therefore widely available.Screenshot:
Tested in Ubuntu 17.10.
If your wi-fi access point is saved, it will auto-connect. Turn wireless on or off with a simpler command:
on newer version:
For reference, see
man nmcli
.If you want to connect to a network called
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 wordpassword
followed by the actual password)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)which will output something like
To forget a connection (that was saved after you ran
nmcli -a d wifi connect <name>
)To see a list of all saved connections
You can use
nmcli connection
instead ofnmcli c <whatever>
andnmcli device
instead ofnmcli 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: