Write List of Packages installed via Manual Invocation of apt-get to File

I'm trying to install a new version of Ubuntu from scratch, but I would like a list of the packages which I manually installed (as opposed to installed as a dependency or that came with the system).

I can get a reasonable approximation on Synaptic by looking at only my Installed (manual) packages and then only looking at those packages not supported by Ubuntu (i.e. all those files without the Ubuntu Unity symbol next to them). However, I cannot seem to get Synaptic to export a list of these packages.

Hence my question is whether it is possible to generate a list of packages that were installed manually via the apt-get install command?

The following do not work:

  • Using apt-mark showmanual. It yields all packages deemed essential as well as manually installed packages. I only want my manually installed packages.
  • aptitude search '!~M ~i'. There are way too many packages that are being shown (no way I manually installed > 1000 packages).
  • The Python script given by @txwikinger in Generating list of manually installed packages and querying individual packages. There are packages (such as bsdgames) which I installed, but do not show up in the output of that script.
  • The bash script given by @Johan in https://serverfault.com/questions/133681/generating-a-list-of-installed-packages-in-ubuntu. Once again too many packages are shown.

This question is similar in flavor to other questions that have been asked both on Stack Exchange sites and elsewhere (such as Generating list of manually installed packages and querying individual packages, https://serverfault.com/questions/133681/generating-a-list-of-installed-packages-in-ubuntu, and http://ubuntuforums.org/showthread.php?t=947865&page=2).

David Kalnischkies on http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=727799 gives some perspective as to why pinning down exactly what "manually installed" means is difficult (e.g. do programs which you ran which installed packages count as "manually installed"?). Therefore I have specifically limited this question (unlike the others that I listed) to only invocations of apt-get install.

Edit: How to view a list of packages that were manually installed without their dependancies has a nice idea for using the log files of apt-get to do this. Unfortunately this doesn't keep track of which packages have been removed. And even if I were to simply grep 'apt-get purge' and take the diff of the two lists that I get it still wouldn't account for the edge case that I've installed a package, uninstalled it, and then reinstalled it.


Solution 1:

Since no answer using apt has been found, I would suggest going into Synaptic Package Manager, click on the Status button at lower left then click on Installed (manual) at upper left to see a list of installed packages.

List from Synaptic of installed packages

Then you can output a list from Synaptic with File | Save Markings As and save the file where you can work with it.