24

I see that I can delete networks that my machine "remembers" from nm-applet by clicking on the wireless icon in the panel and selecting "edit connections" -> "wireless". However, sometimes I click on the wrong wireless connection by accident in the dropdown list. If the connection is secure, the machine of course never successfully connects, but somehow it still seems to memorize the ESSID. Whenever I'm in range of that wireless, it now tries to connect.

Worse, if not connected to any other network, it repeatedly prompts me to connect to this network. If left unattended, I may find dozens of copies of the window prompting me to log in to this mistaken network. There must be a file somewhere that records this connection ID, but I cannot find it. The only connections appearing in the "edit connections" I mention above are those to which I've actually connected. How do I find the file and delete the line corresponding to the offending "memorized" network?

EDIT I seek a solution to remove those networks from whatever list they get added to when I first select them. It appears this behavior is a bug in the network manager(?)

5 Answers 5

33
+50

have you tried to delete the files in the directory /etc/NetworkManager/system-connections/ ?

You should have 1 file for every net you have tried to connect, open a terminal and use the commands:

sudo ls -l /etc/NetworkManager/system-connections/

To list all the files, after you have found the network that you want to delete, remove them with the command:

sudo rm /etc/NetworkManager/system-connections/NETWORK_NAME
4
  • 1
    Awesome, thanks! I wonder why this list is different than the one provided in the Network Applet GUI?
    – cboettig
    Jan 5, 2013 at 19:47
  • This worked man. Dec 18, 2014 at 19:32
  • 3
    By after rebooting, Those names reappear again!
    – Anwar
    Apr 4, 2015 at 17:33
  • "I wonder why this list is different than the one provided in the Network Applet GUI? " - Because networkManager is one of the worst packages in Linux world? Only systemd is worse..
    – kakaz
    Sep 8, 2020 at 12:03
15

You can delete connections using nmcli con delete (CONNECTION_NAME)

To delete all connection never used ( no root needed )

nmcli --fields UUID,TIMESTAMP-REAL con show | grep never |  awk '{print $1}' | while read line; do nmcli con delete uuid  $line;    done
4
  • Great answer. To remove all connections do: nmcli --fields UUID,TIMESTAMP-REAL con show | awk '{print $1}' | while read line; do nmcli con delete uuid $line; done
    – Nathan B
    Oct 5, 2019 at 17:40
  • This should be the accepted answer.
    – Ivan Perez
    Feb 17, 2020 at 18:11
  • I accidentally added a near hundred wrong configurations to my network manager, thanks hero, you save my day with oneliner.
    – Lyoneel
    Apr 30, 2020 at 22:01
  • You should not use NetworkManager at first place.
    – kakaz
    Sep 8, 2020 at 12:03
1

If your major problem are those annoying prompts asking you to log in to a network, then whenever you are not using Wireless, you can just Disable Wireless by clicking the Enable Wireless entry in your Network Indicator Menu.

1
  • Yeah, that's my current solution in a poor connectivity area. However, I usually do not get prompted unless I have attempted to connect to that network before. If I have connected successfully, I can delete it from the list and not get prompted about it. My question is about where to find the record for networks that do not show up there but are clearly memorized by the machine. The record file must exist somewhere
    – cboettig
    Dec 10, 2012 at 17:45
0

Adding more flexibility to the previous answer by @Postadelmaga, I've spent some more effort printing the name of the SSID being removed. This added a difficulty: we now have to avoid the possibility of a SSID name containing the word "never" accidentally matches the timestamp containing "never".

I've also created another function which removes a connection by name.

Sources at: https://github.com/frgomes/debian-bin/blob/master/bash_20nm.sh

#!/bin/bash

function nmcli_list {
  nmcli --pretty --fields NAME,UUID,TIMESTAMP-REAL con show
}

function nmcli_remove {
  if [ ! -z "$1" ] ;then
    nmcli --fields NAME con show | \
      grep "$@" | \
        while read name ;do 
          echo Removing SSID "$name"
          nmcli con delete "$name"
        done
  fi
}

##################################################################################
# The intent here is avoid that a connection named "never drive after you drink" #
# matches a timestamp "never". So, we have to make sure that we match colon      #
# followed by "never" followed by spaces and/or tabs and finally an end of line. #
#                                                                                #
# WARNING: However, I didn't get a chance to test this scenario.                 #
#          So, I provide this code the way it is, in the hope that I've covered  #
#          well the behavior from some other simulations I did.                  #
##################################################################################

function nmcli_remove_never_used {
  nmcli --terse --fields NAME,TIMESTAMP-REAL con show | \
    egrep -e ':never[ \t]*$' | \
      sed -r 's/:never[ \t]*$//' | \
        while read name ;do
          echo Removing SSID "$name"
          nmcli con delete "$name"
        done
}

Then you can delete a specific connection as shown below:

$ nmcli_remove ScalaX
$ nmcli_remove "My WiFi @ Home"
$ nmcli_remove "never drive after you drink"
0

Delete all connections:

nmcli --pretty --fields UUID,TYPE con show | grep wifi | awk "{print $1}" | while read line; do nmcli con delete uuid  $line; done

You must log in to answer this question.

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