Is there any way to get a list of all user-installed packages on an Ubuntu system, i.e. the packages that were installed on top of the default installed packages?

(The idea is to get a comprehensive list that can be used to install the same packages on a clean Ubuntu installation)

link|improve this question

60% accept rate
feedback

6 Answers

up vote 3 down vote accepted

Look at these files,

  1. '/var/log/installer/initial-status.gz' -- your primary installation
    • this file date would be your installation date (i think)
  2. '/var/log/dpkg.log' update timeline (this is what you want)
  3. '/var/log/apt/term.log' -- things apt updated on your system
  4. '/var/cache/apt/archives/' will contain the deb packages downloaded for installation


Update: use the following two steps for exact list of new installs,

execute: grep -w install /var/log/dpkg.log > full-list.log
Look at lines beyond the /var/log/installer/initial-status.gz timestamp

Since, you want to get a clean installation on another system with these packages,
you could even copy the 'deb' files from the 'cache/apt/archives' path
to that of the new installation and get them installed in one shot (without downloading them again).

link|improve this answer
Thanks for the tip. It's useful, although I was looking more for a single command to get this list. cat /var/log/dpkg.log | grep 'install ' seems to come close if I ignore the items installed up to the installation date/time – Rabarberski Sep 29 '09 at 11:49
Adding a reason for the down-vote would help understand a problem in the answer, if there is one. Would also lead to better answers in future. – nik Oct 4 '09 at 6:25
Oeps, the downvote was accidentally mine. I had already upvoted your answer. When I tried to mark your answer as 'final' I missclicked and hit the down vote arrow. Trying to undo it displayed the message: "Vote too old to be changed, unless this answer is edited." Sorry nik, both for the downvote and the confusion. :-( – Rabarberski Nov 10 '09 at 13:58
@Rabarberski, well that happens... no harm done. – nik Nov 10 '09 at 16:31
does not work if /var/log/installer does not exist, like on a server install. Also it would make sense to add VERSION NUMBERS if you are talking about "Ubuntu" - which Ubuntu? – user99950 Oct 2 '11 at 13:18
feedback

Check my answer here to a related question: How can I display the list of all packages installed on my Debian system?. Some of the other answers on the question also contain nice suggestions on getting such a list.

This question should be marked a duplicate since the earlier question also covers this question, but it might be useful to have this question stand on its own so it's easier to find.

link|improve this answer
feedback

Based on the information above, I wrote a short Python script to list packages that were manually installed. See http://www.aifdr.org/projects/system_administration/browser/statistics/list_manually_installed_packages.py

Feel free to use it although I assume no responsibility for it. However, feedback and suggestions are always welcome.

Ole Nielsen

link|improve this answer
Brilliant! It takes a while to run, but it's the only solution I've found which does exactly what I need! – haxney Feb 23 at 20:05
feedback

Just for grins, I put together a one-liner (here split for clarity) that figures out packages manually installed, excluding those installed initially and any packages automatically installed:

comm -13 \
  <(gzip -dc /var/log/installer/initial-status.gz | sed -n 's/^Package: //p' | sort) \
  <(comm -23 \
    <(dpkg-query -W -f='${Package}\n' | sed 1d | sort) \
    <(apt-mark showauto | sort) \
  )

Not sure if this works in bash, but it does in zsh.

link|improve this answer
This works almost perfectly, except it seems to print out a bunch of libraries installed during the initial install. There's a bunch of libtiff, libxcb, etc which I didn't install myself. This answer: superuser.com/a/105000/24349 takes care of that by sorting according to install time and removing everything before the system install time. Great (ab)use of shell! – haxney Feb 23 at 20:12
feedback

This is a hack-job, but it completely works.

First, go to http://releases.ubuntu.com/maverick/ (or whatever version of Ubuntu you're using) and grab the *.manifest file that is associated with the version of Ubuntu you're using. Then, run the following script (replacing , angle brackets and all, with the path to the file you downloaded. You can always append "> output" to the end to make a file dump (without quotes, of course).

diff --suppress-common-lines <(sed 's/ .//' ) <(dpkg --get-selections | sed 's/[ \t].//') | grep '>' | sed 's/[>] //'

link|improve this answer
feedback

Thanks geekosaur, nice code - I used this but it took a while to figure out how to get it working. Here's how I did it in Ubuntu 11.10 - it works in the bash terminal:

comm -13 \
  <(gzip -dc /var/log/installer/initial-status.gz | sed -n 's/^Package: //p' | sort) \
  <(comm -23 \
    <(dpkg-query -W -f='${Package}\n' | sed 1d | sort) \
    <(apt-mark showauto | sort) \
  ) > user-installed-packages

Then to add a tab - '\t' - and 'install' on each line: sed 's/$/\tinstall/' user-installed-packages >uip

Then on the new machine:

sudo dpkg --set-selections < uip

And to install the packages:

sudo apt-get dselect-upgrade
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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