To list current priorities
$ nmcli -f autoconnect-priority,name c
AUTOCONNECT-PRIORITY NAME
0 Blake5Net
0 Caffe Ubuntu
0 Caffe Ubuntu Guest
0 Fire Hotspot
0 JET & Mishka
0 La Marzocco
0 Le_MX
0 MobileLab
0 xfinitywifi
Tip: If you have a very long list, you may want to sort them by priority:
nmcli -f autoconnect-priority,name c | tail -n +2 | sort -nr
nmcli connection modify "Caffe Ubuntu" connection.autoconnect-priority 10
How to set a network as a last resort
nmcli connection modify "xfinitywifi" connection.autoconnect-priority -10
Negative priority values are lower than the default of 0, which means they will be tried last, if no other known WiFi network can be found. Note that, due to a bug in some versions of nmcli, you may see negative numbers listed as huge positive numbers like 4294967286. Don't worry about this as it will still work fine.