Tell me more ×
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

6 Answers

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
+1, thanks for the explanation. – 0xC0000022L Mar 25 '11 at 18:07
2  
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

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:

gnome-do
texlive-full
...

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 1 down vote accepted

I finally got it now:

outfile="$(mktemp)"
pattern='(\[INSTALLIEREN\]|\[INSTALL\])'

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

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

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
3  
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

Your Answer

 
discard

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.