Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. 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

I'll change my system from 32 bits to 64 bits, and will be the same I had before, Debian Squeeze, but I do not want to lose the programs I installed before, because I do not remember the name of them all.

So I wanted a command to do this for me, save the name of all the programs I installed on a file, but not the standard programs that came with the system, and when I'm using the other system I would mention the name of the file and your directory for everything to be installed automatically.

One more question: is it possible to do this with programs that were installed manually with dpkg-i package.deb? If so, how can I do that?

share|improve this question
up vote 6 down vote accepted

Have you tried to use dpkg --get-selections >packages? If you want to exclude some packages, you can edit the output file packages. When you're done, transfer it to the target system and say:

dpkg --set-selections <packages

And packages will be marked for installation. You'll most likely also need to say aptitude update; aptitude dist-upgrade.

The other question: if those packages are i386 architecture packages, and you have multiarch installed, you can install the .debs with the usual dpkg -i package.deb. But it's probably better to investigate on a case-by-case basis and install 64 bit versions of those packages that have them.

share|improve this answer
Thanks, you really helped me when you said about the packages already installed are in i386 architecture, I hadn't thought about it, I think is better re-install those others. – Zignd Jun 21 '12 at 13:52

On current Debian versions, you can get a list of explicitly-installed packages with

apt-mark showmanual

For those running ancient versions of Debian where apt-mark showmanual doesn't exist, or if you want to perform additional selections, you can use aptitude.

aptitude search '~i !~M' -F %p >package.list

~i matches installed packages; !~M omits the packages that were installed automatically as a dependency of some other package. -F %p changes the output format to include only the package name.

You can later install those packages with

apt-get install $(cat package.list)

Debian squeeze doesn't have apt-mark showmanual, but it has apt-mark showauto which lists automatically-installed packages. If you use this, you can list all packages on the old system with dpkg --get-selections >package.list, restore all of these, and then mark the automatic packages with apt-mark markauto. For your use case (32-bit to 64-bit), this approach is likely to leave a few libraries marked as manual, because they have different names under different architectures.

Note that if the use case is to reproduce an identical installation, rather than keep the set of packages but change the architecture, there is now a tool called apt-clone (distributed in Debian since wheezy) that does everything automatically.

share|improve this answer
Unfortunately, this isn't perfect. When I do this, the first thing that's listed is "acl", which I did not explicitly load. Looking at rdepends, it seems that systemd depends on this, and in Debian 8 that is already installed. And, systemd is also on this list. So even though systemd and acl came installed, aptitude does not identify them as "automatic". Could this be a deficiency in aptitude? – Liam Dec 1 '15 at 18:37
@Liam I think the installer doesn't mark any package as automatic. Even if it did, which would make sense for libraries, a package like acl might be considered an important part of the base system and so would be marked as manually installed. It was “manually” installed by the initial installer rather than by the user, but even so, the meaning of “automatically installed” is “you can safely remove this if it doesn't break dependencies”, and fundamental packages needed to make the system work properly don't fit the bill. – Gilles Dec 1 '15 at 18:49

I don't see a simple, standard way to do so. I'm afraid you'll have to fiddle with dpkg's logs and options, because dpkg doesn't distinguish the "standard programs that came with the system" and the others.

THIS WON'T BE STRAIGHTFORWARD, I prefer to make it clear by using bold capitalized text, but you can do something like this

  • Extract the list of installed software from the /var/log/dpkg.log* files.

  • Remove those installed during system install. (Use the install time to detect them)

  • Save the list in the dpkg --get-selections format

Et voilà! When your system is up and running, reinstall your programs with

 apt-get update
 dpkg --set-selections < yourSelection
 apt-get -u dselect-upgrade
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.