9

Is there a way to list all non-free and contrib software installed in Debian via apt?

/etc/apt/sources.list is as follows

deb http://ftp.us.debian.org/debian/ wheezy main non-free contrib
deb-src http://ftp.us.debian.org/debian/ wheezy main non-free contrib

deb http://security.debian.org/ wheezy/updates main non-free contrib
deb-src http://security.debian.org/ wheezy/updates main non-free contrib

# wheezy-updates, previously known as 'volatile'
deb http://ftp.us.debian.org/debian/ wheezy-updates main
deb-src http://ftp.us.debian.org/debian/ wheezy-updates main

I added non-free and contrib years ago because I needed a non-free driver for my video-card, which has now been replaced with a new one that doesn't require a non-free driver. I'd like to get rid of the non-free stuff, but I'm afraid I might have installed other non-free software over the years which I cannot afford to uninstall.

13
  • dpkg-query -W -f='${Section}\t${Package}\n' | grep ^non-free
  • aptitude search '~i ?section(non-free)'

Section will be non-free/... for everything from the non-free path.

[Note] for gcc docs...

 This documentation is licensed under the terms of the GNU Free
 Documentation License, and contains invariant sections, so it can't be
 part of Debian main.

(I wondered about that too, but didn't bother checking until it was mentioned.)

  • Both yielded different results (pastebin.com/rAhYHTk8). The NVIDIA stuff is the driver, so dpkg seems right! Upvoted. I just wonder what gcc-doc is doing there. – Alex Jan 27 '14 at 10:13
  • The NVIDIA stuff was already removed, apt probably listed it because it kept the .deb or something. I just remembered one thing I have from non-free which wasn't listed: dpkg -l | grep -i nonfree results in flashplugin-nonfree. I wonder why that wasn't listed by aptitude and if it's actually listing everything from non-free. – Alex Jan 27 '14 at 10:22
  • 2
    Because it's in contrib :: debian/pool/contrib/f/flashplugin-nonfree (Section: contrib/web) – Ricky Beam Jan 27 '14 at 10:37
  • 1
    A one-liner for both sections is dpkg-query -W -f='${Section}\t${Package}\n' | sort | egrep ^contrib\|^non-free – GKFX Jul 12 '15 at 10:02
  • Regarding dpkg-query -W -f='${Section}\t${Package}\n': Section does not display the components. (At least, it does not for me on Ubuntu 18.04.) An example component might be main, contrib, or non-free. Whereas sections are things like: admin, gnome, utils, or x11. – mpb Aug 23 '18 at 16:20
6

There is a program called VRMS (a virtual Richard M. Stallman) which will report all the non-free software on your system in a short summary. Its in the repo's and you can install it via apt ;-)

  • 2
    It's worth mentioning vrms adds itself to /etc/cron.monthly. I was pleasantly surprised when I got a mail from virtual Stallman a month after the install. – Alex May 7 '14 at 18:49
2

I had a similar 'urge' a few years ago and could not determine that the orginal package information is kept on the system after downloading the package. I don't think this information is available to dpkg.

So what I ended up was setup a clean virtual machine, setup the appropriate /etc/apt/sources.list and installed the whole list generated by:

dpkg --get-selections | fgrep -v deinstall | cut -s -f 1

the packages that would not install (I only did download to save some time with apt-get -d).

You might be able to do a similar thing using apt-get --root-directory=some_dir after temporarily changing your sources.list, but I would not sure if that uses your current install database and just moves the package there. A VM for this kind of experimenting is much safer. I normally have a clean basic install of my current Linux as VM, so I only have to clone that (not that installing Linux on a VM takes that long).

  • Nice "solution". I currently don't have the disk space for it, but I imagine apt will first display the packages that weren't found (hence are non-free), correct? – Alex Jan 27 '14 at 10:14
  • @Alex Yes that is correct. That is kind of missing from the answer. But Ricky's approach is better unless the unlikely happened and a package actually moved over time from one repo to another (and you are not up-to-date or the package did not change version number). – Timo Jan 27 '14 at 12:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.