I'm trying to get an authoritative list of installed packages in order to find the explicitly installed ones as is done here.

This command gives me one list

aptitude search '~i !~M' -F '%p' --disable-columns | sort -u

And this gives me another

apt --installed list | cut -d'/' -f1 | tail -n +2 | sort -u

The second command lists more packages, and some of these I'm able to run from the command line. I'd prefer to use apt because it's a default package. Which list is authoritative?


Your aptitude command is searching for installed packages but excluding packages that were installed automatically !~M. Of course it gives a different list than apt -installed. These two command will return the same list:

aptitude search '~i' -F '%p' 
apt --installed  list 
  • So if I installed a package but told it to install all required dependencies as well, those would be considered automatically installed? – user1837378 Oct 16 '15 at 12:14

Since you want to have the authoritative list, you should use the tool that actually handles packages, rather than one of its frontends. That tool is dpkg.

If you run

dpkg -l

then you will get a list of all the packages that dpkg knows about; this includes packages that were removed but not purged, as well as packages currently installed. It does not necessarily include packages that are not installed at all, although it may. To figure out which is which, check the legend at the top, and the first three characters of the output.

For example, to print only installed packages, use:

dpkg -l | grep ^ii

I ran dpkg -l > pl.txt. Then compared the packages listed with what the Synaptic Package Manager said was installed. There was a complete one to one mapping between the two. I now save the pl.txt file to my Google Drive periodically. If I every have to re-install my system, I'll use the stored text file list to re-install those packages I've been using.

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.