Apt: list packages installed from a particular "component" (main/contrib/non-free)

ru flag

I'd like to check which packages were installed from non-free component on my server, following the recent announcement by the Debian team

I briefly looked into man dpkg, man apt-cache but couldn't find a quick answer to my question. Could anyone suggest a command or a one-liner?

(I didn't even know the main/contrib/non-free field is called a "component": )

ru flag
$ dpkg-query --show -f '${Package} ${Version} ${Section}\n' | grep -E ' non-free/\w+$'
amd64-microcode 3.20220411.1 non-free/admin
bluez-firmware 1.2-8 non-free/kernel
firmware-amd-graphics 20221214-3 non-free/kernel
firmware-linux 20221214-3 non-free/metapackages

I'm not sure if this is documented anywhere, apparently the Section field is qualified by a "component", so by printing it out with ${Section} we can filter entries by component.

This option is used to specify the format of the output --show will produce ...snip...

Actually, all other fields found in the status file (i.e. user defined fields) can be requested, too. They will be printed as-is, ...snip...


Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.