Tuesday, May 14, 2024
 Popular · Latest · Hot · Upcoming
258
rated 0 times [  258] [ 0]  / answers: 1 / hits: 601840  / 3 Years ago, fri, october 15, 2021, 12:51:08

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

More From » wireless

 Answers
6

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>)



    nmcli c

  • To see list of available WiFi hotspots (<WiFiSSID>)



    nmcli d wifi list


    or:



    sudo iwlist <WifiInterface> scanning

  • To see list of interfaces (<WifiInterface>)



    ifconfig -a



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



##disconnect
nmcli d disconnect <WifiInterface>

##connect
nmcli d connect <WifiInterface>


Another way:



##disconnect
nmcli c down <SavedWiFiConn>

##connect
nmcli c up <SavedWiFiConn>


Ubuntu 15.10 & previous



##disconnect
nmcli d disconnect iface <WifiInterface>

##connect
nmcli d wifi connect <WiFiSSID> password <WiFiPassword> iface <WifiInterface>


Another way:



##disconnect:
nmcli c down id <SavedWiFiConn>

##connect:
nmcli c up id <SavedWiFiConn>


If your password isn't automatically recognized type this:



nmcli -a c up <SavedWiFiConn>


Reference: man nmcli


[#25389] Saturday, October 16, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
lowstonnequ

Total Points: 279
Total Questions: 125
Total Answers: 123

Location: Finland
Member since Sun, Dec 5, 2021
2 Years ago
;