Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

So I can run on one machine:

dpkg --get-selections '*' > selection.txt

On another machine:

dpkg --set-selections < selection.txt

... followed by either of the following:

aptitude install
apt-get -u dselect-upgrade

... to install the packages that.

However, it appears that some information gets lost in the process, such as whether a package (say xyz) got installed automatically as dependency of another package (abc). You can see that whenever you do something like apt-get --purge remove abc. On the original machine you would be notified that package xyz was installed as dependency of abc and that you may use apt-get autoremove to get rid of it.

Now I am aware of deborphan and debfoster, but they're cumbersome to use given the (simple) task at hand.

It seems saving and restoring the selections as shown above is not sufficient to restore the subtle dependencies of installed packages.

Is there a way to back up the complete set of metadata for package management and restore it then in its entirety?

share|improve this question
I've often wondered the same thing I generate a big shell script with a 'sudo apt-get install' with all my packages (minus libs). Of course, I run into the same problem you're having. – Chuck R Feb 20 '12 at 18:17
I would guess that the best place to start looking would be to check if dpkg is in fact responsible for that information. If it isn't then maybe that is apt's job. – Huckle Feb 20 '12 at 19:03
If you're going the manual way, you may be interested in apt-mark for saving/restoring information about automatic vs manually installed packages – Lekensteyn Feb 24 '12 at 18:37
It's not in the 10.04 package repo, is it? Is this part of the Canonical repos or third-party? – 0xC0000022L Feb 24 '12 at 19:59
No, that's just a "for your information" comment. I'd use apt-mark (it's part of apt, so it should already be installed) to get and set the marks for the packages (see its manpage for details). – htorque Feb 27 '12 at 12:07
up vote 30 down vote accepted


apt-mark showauto > pkgs_auto.lst
apt-mark showmanual > pkgs_manual.lst


sudo apt-mark auto $(cat pkgs_auto.lst)
sudo apt-mark manual $(cat pkgs_manual.lst)
share|improve this answer
Thanks, was about to ask that you or Lekensteyn write that up as an answer. – 0xC0000022L Feb 29 '12 at 17:51
Does these commands allow you to reinstall the programs from that list? – Svetlana Belkin Dec 30 '13 at 14:35
can this remove packages that are installed extra, at restoration? – n611x007 May 22 '14 at 11:56
Can you explain the difference between auto and manual ? Thanks. – Anto Jan 7 '15 at 16:33
rtfm man apt-mark. You'll also find other possibilities. – Dave Apr 11 at 16:45

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.