This question comes from the Software Recomendations StackExchange site . In a beginning I thought that was the proper place, but some people suggest this Unix forum fits better.

When an Operating System has several wireless networks available (and known, this is: in its "preferred" list), it is supposed to do an intelligent management of roaming between them, usually connecting to the best one (measuring it by several factors, like coverage or speed).

But, when working with some Linux distros (for example the intended for security auditing ones), I have found such management not so intelligent: sometimes the net keeps down (not behaving completely OK) and the operating system stays on that wireless network.

So, I was thinking about doing a script myself to force Linux to select another wireless network when the connected one slows down or directly fails (maybe checkable by pinging the router/access point).
For what I have read about command-line wireless management, the "connect to" thing seems a bit awkward: issuing multiple commands, editing files... etc.

Does anyone know about a good "switch-to-network" command-line tool running under Linux? Remember I don't need to connect to a new network: I just want to connect to an already-some-day connected network, so the operating system is supposed to know the password, encryption data and so on.

Possible command-line examples:

switchtowifi --essid MyWiFiNetwork
switchtowifi --essid MyWiFiNetwork --bssid 11:22:33:44:55:66
switchtowifi --channel 5

The first example switches to any already-stored WiFi network named MyWiFiNetwork.
The second example switches to the already-stored WiFi network named MyWiFiNetwork whose BSSID is 11:22:33:44:55:66.
The third example switches to any already-stored WiFi network on channel 5.

  • 1
    I'm voting to close this question as off-topic because You should not crosspost question betwqeen different stackExchange site. Next time please flag your own question and ask a moderator to migrate your question on the correct site.
    – Kiwy
    Mar 26, 2019 at 10:44
  • 1
    @Kiwy , maybe the correct question to close is the one at the Software Recommendations site? Mar 26, 2019 at 17:47
  • indeed you are right
    – Kiwy
    Mar 26, 2019 at 17:51

2 Answers 2


Solution using the nmcli tool, included in most distros or easily installable via apt-get, yum ... etc :

To show already-stored WiFi networks:

$ nmcli con
NAME            UUID                                   TYPE              TIME
Wireless-1      28d6c265-xxxx-4e83-907f-ecb5ab3ac37c   802-11-wireless   Thu 
Wired-Network   30d29da3-xxxx-4ea2-94ff-0edac8954ff7   802-3-ethernet    Sun 
Wireless-2      89f31b44-xxxx-4b7d-abb1-8242a1fa7040   802-11-wireless   Thu 
Wireless-3      6adcb4e8-xxxx-4e88-bf50-872d9e5eb1f3   802-11-wireless   Fri 
Wireless-4      8c4fc701-xxxx-472e-aecc-40131c0d8d31   802-11-wireless   Fri 

Note the network is stored by a unique UUID identifier.

To connect to any of these networks (example for Wireless-1):

$ nmcli con up uuid 28d6c265-xxxx-4e83-907f-ecb5ab3ac37c

See the man page for more functions, like forget, disconnect, scan or connect to new (not yet stored) network.
The nmcli tool is great: it can work with a specific wireless device (i.e: wlan0) or with any of them in a generic manner (i.e: you just specify wifi and the tool makes in charge of establishing the connection).

Info extracted from here.
Thanks to @ThatGuy for the link.


wicd-curses might be an option:

wicd-curses screenshot
(source: atastypixel.com)

There's also nmcli.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .