10

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?

4 Answers 4

11

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.

2
  • 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
    Commented Dec 1, 2015 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. Commented Dec 1, 2015 at 18:49
8

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.

1
  • 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
    Commented Jun 21, 2012 at 13:52
2

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
0

I am trying to figure out how to do the same on a RHEL/Fedora system that uses RPM packaging. I found sudo dnf history to be helpful, but that command only lists out what was installed by the user AFTER the system was installed by the anaconda installer, for example.

Here's the command I use:

sudo dpkg -l|awk '/^ii/{ print $2 }'|grep -v -e ^lib -e -dev -e $(uname -r) > /path/to/your/filename000.txt

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.