How to forget wireless networks from command line?

3

Using the command line on Debian, how can make the system forget the wireless networks I previously connected to?

Thanks.

thedp

Posted 2015-12-19T00:23:27.927

Reputation: 255

Answers

1

Got the right answer here: https://askubuntu.com/a/711634/95664

My adaptation to the given solution with a small python script:

#! /usr/bin/env python

import commands
import os

res = commands.getstatusoutput("nmcli -t -f TYPE,UUID con")
lines = res[1].split('\n')

for line in lines:
    parts = line.split(":")
    if (parts[0] == "802-11-wireless"):
        os.system("nmcli connection delete uuid "+ parts[1])

print ">> Done."
os.system("nmcli connection")

thedp

Posted 2015-12-19T00:23:27.927

Reputation: 255

If you want to forget just a single network, you can see the network names by including the NAME field in the first command: nmcli -t -f TYPE,UUID,NAME con – Michael – 2016-04-17T20:58:06.183

0

I assume your wireless interface is named after wlan0 but please modify it according to your setting.

You could try:

  • sudo dhclient -r wlan0 (-r flag will renew or release the current IP addr from your wirless interface).

You can also do:

  • sudo dhclient wlan0 to request a new IP.

lakedejavu

Posted 2015-12-19T00:23:27.927

Reputation: 1

This doesn't remove the WiFi network from known networks list. – thedp – 2015-12-24T18:30:25.827