15

Let's say that network-manager is connected to specific Wi-Fi network. When I click "Disconnect" via GUI from it then it never connects back.

But when I close the laptop lid, then open it back (so that system suspends and resumes) then network-manager automatically connects to the Wi-Fi network it finds.

How do I trigger network-manager from console to automatically connect to the Wi-Fi network it finds without doing system suspend and resume?

Te Ri
  • 1,038

2 Answers2

17
nmcli device set IFNAME autoconnect yes

is the command you're searching for. It enables autoconnect for the device with the interface name IFNAME, see e. g. nmcli device to get this name. If the device is currently not connected but finds a network it can connect to when you execute this command, it will instantly connect.

dessert
  • 40,956
16

device as suggested only works if the connection is existing/up.

If you want the setting to be permanent, you need to modify the connection config instead of the device config:

nmcli connection modify CONNECTION_NAME connection.autoconnect yes|no
bluppfisk
  • 890