0

I'd like to delete all active or inactive Wifi connections on interface wlan0, with the intention of having a known-empty clean slate to set things up. Is this possible?

I was hoping for something like

nmcli connection delete device wlan0

or

nmcli dev show wlan0 delete

but no such luck.

Or is there a means to do this with iw? I found a means to delete the interface, but not connections.

1
  • Try "ip link set wlan0 down". It will certainly kill all the connections, It's not clear what you mean by a "clean slate". If you have SSID broadcast turned on then connections may re-connect. Commented Aug 19, 2021 at 21:01

2 Answers 2

4

nmcli --terse connection show will list connections as lines with colon-separated fields. So you could do something like this:

nmcli --terse connection show | cut -d : -f 1 | \
  while read name; do echo nmcli connection delete "$name"; done

This will display a series of nmcli connection delete commands, one per line. If the output looks correct, remove the word echo and it will execute the commands instead of displaying them.

\ indicates that a long line has been split in two for readability; if you write it all in one line, you should omit the \.

1
  • 3
    You could use nmcli --terse --fields=name (or equivalently nmcli -t -f name) to avoid the need for cut here I think - also note that this will delete connections on ALL interfaces (not just "on interface wlan0") Commented Aug 19, 2021 at 23:26
0

nmcli connection delete <connection name> works fine for me. It deletes connections (like the known wifi networks and such).
Using iw you can add and delete devices (like wlan0). Requires root privilage. sudo iw dev wlan0 del
To create new one: sudo iw phy phy0 interface add wlan0 type managed
Here phy0 is the physical device of your computer (NIC or such). To know the name of phy use iw phy. It'll return a list of physical devices and their capabilities.

1
  • I can do nmcli con del <name> for single connections I'm trying to find if something like 'nmcli connection delete ALL dev wlan0' exists. Ie, take down -all- my wifi connections in one shot. Commented Aug 19, 2021 at 18:23

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.