1

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

1 Answer 1

3

For connections managed via network-manager, it should be possible to do that via the nmcli interface e.g. to delete wireless connections older than one day

nmcli -t -f TYPE,TIMESTAMP,UUID con list | 
  awk -F\: -v oldts="$(date +%s -d '1 day ago')" '$1 == "802-11-wireless" && $2 < oldts {print $3}' |
  while read -r uuid; do
    nmcli con delete uuid "$uuid"
  done

or (perhaps a bit nicer) something like

#!/bin/bash

oldstamp=$(date +%s -d '1 day ago')

while IFS=\: read -r contype timestamp uuid
do
  case "$contype" in
    802-11-wireless)
      if ((timestamp < oldstamp)); then
        nmcli con delete uuid "$uuid"
      else
        echo "$uuid: too new: skipping"
      fi
    ;;

    *)
      echo "skipping connection type $contype"
    ;;
  esac
done < <(nmcli -t -f TYPE,TIMESTAMP,UUID con list)

The privilege escalation should be handled by dbus/policykit, so sudo shouldn't be required to delete connections created by the invoking user.

You must log in to answer this question.

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