Grimoire-
Command
.es

GNU+Linux command memo

List local or obsolete packages in Debian-base distributions

Lister les paquets locaux ou obsolète d’une distribution GNU+Linux basées sur Debian

$ sudo apt install apt-show-versions
$ apt-show-versions | grep -v buster (1)
$ apt-show-versions | grep -v buster | awk '{print $1}' | xargs apt remove (2)
1 List all packages and remove those with buster in the line, so belonging to the current stable version of Debian
2 Selecting, in addition, the 1st column and apply apt remove on each result
This will also remove the local packages, that where never part of the official distribution.

For an interactive removal, one packet at a time:

$ for i in `apt-show-versions | grep -v buster | grep -v 'not installed' | awk '{print $1}'` ; do sudo apt remove $i ; done

Thanks to : Arthur Lutz.