Finding Debian packages installed from backports.debian.org

Using backports is a nice way to get newer versions of software while continuing to use Debian stable. If you ever want to list the packages installed from the backports repository, aptitude can help:

aptitude search '~S ~i ~O"Debian Backports"'

You get the search term "Debian Backports" (the so-called origin) for the backports packages from the output of

apt-cache policy

For a list of valid origins depending on your APT sources, we can filter this by using grep and sort:

apt-cache policy | grep -o o=[^,]* | sort -u

So of course this also works to find out which packages got installed from other repositories.