Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I installed a plain Ubuntu 10.10 on my computer and installed some software via apt-get. Last week I managed to break everything and just started from scratch, and I need to reinstall my software. Is there some way to create a list with all the packages that I have installed manually?

So that it would give me a list like „texlive, ...“ and not „texlive, texlive-dep1, textlive-dep2, ...“ and all the standard packages removed?

If I could somehow figure out which programs out of the regular install I have removed, that would be awesome too!

share|improve this question

10 Answers 10

With this suggestion, I'm assuming your old installation will still boot!

To replicate one set of packages on another machine:

On System A, run: dpkg --get-selections | grep -v deinstall > my-selections

Move the my-selections file over to System B.

On System B, run: dpkg --set-selections < my-selections

and then:

sudo apt-get dselect-upgrade

Important note: if you have installed packages from non-standard repositories and/or PPAs, you will also want to copy /etc/apt/sources.list and the contents of /etc/apt/sources.list.d/ from System A to System B before you run the upgrade.

You can use dpkg to see what you've removed as well (NB: this will also include packages that you manually installed and removed):

dpkg --get-selections | grep deinstall

You can see your results in the terminal, or, of course, redirect to a file.

share|improve this answer
I would like to get a list of all packages, but I would like to have only the names of packages that I explicitly installed. So just something and not something-common as well. –  queueoverflow Apr 5 '11 at 14:15
Yeah while this is useful, it doesn't do what the question asks. –  Timmmm Dec 21 '12 at 20:54

This thread from superuser.com gives this solution:

aptitude search '?installed ?not(?automatic)'
share|improve this answer
This doesn't work for me. Just lists everything that is installed, or certainly more than I have explicitly asked for. –  Timmmm Dec 21 '12 at 20:54
It lists everything you have installed with apt-get, plus their dependencies. So, for example, if you installed aptitude, then it will also list apt-xapian-index aptitude-common libboost-iostreams1.54.0 libclass-accessor-perl libcwidget3 libept1.4.12 libio-string-perl libparse-debianchangelog-perl libsigc++-2.0-0c2a libsub-name-perl libtimedate-perl libxapian22 python-chardet python-debian python-six python-xapian –  Runemoro Jun 7 '14 at 14:43

If your apt logs are in /var/log/apt, something like this should work:

gunzip -c /var/log/apt/history.log.*.gz | grep "apt-get install"

Or if you want to get rid of some of the repetitive junk in the output:

gunzip -c /var/log/apt/history.log.*.gz | grep "apt-get install" \
  | cut -f4- -d" " | sort | uniq
share|improve this answer

You could use apt-mark, but I recommend debfoster:

sudo apt-get install debfoster
sudo debfoster

This will inspect all installed packages and figure out which ones are keeping the others installed:

texlive-full is keeping the following 161 packages installed:
  cm-super cm-super-minimal context doc-base dvipng feynmf
  fonts-gfs-artemisia fonts-gfs-baskerville fonts-gfs-bodoni-classic
Keep texlive-full? [Ynpsiuqx?], [H]elp:

As you answer "y" to each question (just push Enter to move quickly), debfoster will collect the package list and write them line-by-line to a file. By default this is at /var/lib/debfoster/keepers. It looks like this:


I configure debfoster via /etc/debfoster.conf to put this list at /etc/debfoster-keepers and track the file with etckeeper to keep history and backups. The answer here shows how to install a list of packages from a newline-delimited text file:

sudo apt-mark manual $(cat debfoster-keepers)

Note a limitation here, packages you purged have a '-' in front of them. So you want to remove those lines before calling apt-mark.

Even though the debfoster's website says that debfoster is deprecated in favor of aptitude, I prefer debfoster's prompt and simple configuration. It puts you in the middle of your package database and lets you clean things up, making the auto and manual packages more obvious.

Type "h" at the debfoster prompt to explain your options. Type "?" to see the package description. The how-to here might be useful.

share|improve this answer
up vote 2 down vote accepted

I finally got it now:


if [[ -f "/var/log/aptitude.1.gz" ]]
        gunzip -c /var/log/aptitude.*.gz | grep -E "$pattern" | awk '{ print $2; }' > "$outfile"

if [[ -f "/var/log/aptitude" ]]
        grep -E "$pattern" "/var/log/aptitude" | awk '{ print $2; }' >> "$outfile"

sort "$outfile"
rm "$outfile"
share|improve this answer
I guess this only works if you only ever installed packages using aptitude. There are similar files in /var/log/apt/history.log(.N.gz) though. –  Timmmm Dec 21 '12 at 20:56

I'm able to pull everything by opening the log files in /var/log/apt/

I then go in and manually filter out the apt-get install packages. There may be a way to do this programatically but I'm not aware of it.

share|improve this answer

See this answer on unix.stackexchange.com for a solution that filters out stock packages.

share|improve this answer
While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. –  Mitch Aug 21 '12 at 7:43
cd /var/log/apt
cat  history.log | grep Commandline

this way you see the list of commands performed in the past.

Remove the grep code if you need more information:

less history.log

if the log is compressed (i.e. end with gz)

gunzip <filename>

to zip it again when finished you can do:

gzip <filename>
share|improve this answer
Instead of uncompressing and recompressing the log files, why not use zcat? It is as easy as zcat filename.gz. One can just use it on gzip compressed files in place of cat. Also grep can be replaced with zgrep, e.g. zgrep Commandline history.log.1.gz. –  lgarzo Jul 2 '13 at 16:18
Based on your idea I've come up with a command line: (grep "Commandline" history.log ; zgrep "Commandline" history.log.*.gz ) | grep " install " | grep -v -- "--yes" | sed -r "s/^.*install //". It has flaws, because the removed packages are also listed, and if a package was installed more than once, it is listed multiple times. –  lgarzo Jul 2 '13 at 16:31

Someone linked to http://unix.stackexchange.com/questions/3595/ubuntu-list-explicitly-installed-packages/3624#3624 which does have a good solution, but, it doesn’t behave correctly as the output from aptitude has changed. Here is an updated version, based around compared currently installed packages compared to 12.04 LTS. You will need aptitude installed, that is the only requirement.

aptitude search '~i !~M' -F '%p' | sort -u | tr -d ' ' > currentlyinstalled && wget -qO - http://mirror.pnl.gov/releases/precise/ubuntu-12.04.3-desktop-amd64.manifest | cut -f 1 | sort -u > defaultinstalled && comm -23 currentlyinstalled defaultinstalled

To break the above command down into parts, this bit outputs one package per line of everything installed on the system

aptitude search '~i !~M' -F '%p' | sort -u | tr -d ' ' > currentlyinstalled

And this downloads the default package list & crops the redundant information.

wget -qO - http://mirror.pnl.gov/releases/precise/ubuntu-12.04.3-desktop-amd64.manifest | cut -f 1 | sort -u > defaultinstalled

and comm compares the two files and outputs the packages which arent in the default list.

comm -23 currentlyinstalled defaultinstalled
share|improve this answer
You can also go to the other site and update the answer there. –  queueoverflow Oct 16 '13 at 7:19
#! /bin/sh
cat /var/log/installer/initial-status.gz | gzip -d | grep '^Package:' | awk '{ print $2}' | sort -u > $DEFAULT
aptitude search '~i !~M' -F '%p' | sort -u | tr -d ' ' | awk '{ print $1}' > $CURRENT
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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