I like to keep the packages installed on a linux box strictly under control — that is one of the benefits I’ve enjoyed from linux since 1994. I had a compicated script that would do that for me, but nowadays it has been superceded by deborphan. That, however, requires recursive calls because once you remove the currently redundant packages, that exposes newly redundant packages whose only role was to support the packages you have just removed. That quickly becomes tiresome, so here’s a quick & easy way to do it.
deborphan --no-show-section -a | sort >/tmp/keep
Then edit /tmp/keep so it only contains those packages you want to keep.
deborphan --no-show-section -a \ | sort >/tmp/a; apt-get --purge remove $(comm -23 /tmp/a /tmp/keep)
[omit the \ and keep all on one line]
It will ask you to confirm removal if it finds any redundant packages. If it does, let it complete then use <up arrow><return> to iterate again. Repeat until no more packages are identified.
Of course, if you see a package that you in fact want to keep, add it to /tmp/keep then repeat.
Some people feel brave and decide they want this to run blindly without confirmation. In that case, put it in a script and use apt-get --purge --assume-yes remove ..., but I don’t like that policy.