Use Aptitude to install all the packages from one Debian or Ubuntu computer to another

Use Aptitude to install all the packages from one Debian or Ubuntu computer to another

This post shows you how to quickly install all the packages on one Debian or Ubuntu system on another.

Assumptions:

You have only installed packages via an APT frontend and have all the same repositories on both computers. Manually compiled software won’t be found, and packages you’ve made yourself and installed via dpkg won’t be available. If you don’t know what any of this means and you built both systems you’re likely ok.

You are using the same distro on each computer (i.e. both are Debian Lenny or Ubuntu Intrepid Ibex. Mixing the two would not be good) with similar hardware.

Both computers are both on the same local network and have the IP addresses of 192.168.2.100 (server0) and 192.168.2.101 (server1).

The name of the user on server0 is username.

The user account on server1 is regular user that can use sudo, not a root account.

Notes:

If you’re installing on different hardware, remove any unneeded drivers from the list.txt file produced using the steps below before using dpkg –set-selections to import the list.

Aptitude is another frontend to APT (slightly less commonly used than apt-get). It works best when you use it exclusively. psychocats.net has a good writeup on the differences between apt-get and aptitude.

Steps:

On the system with the packages:
server0:~# dpkg --get-selections > list.txt

On the system that you want to install the packages on:
server1:~# scp username@192.168.2.100:~/list.txt .
server1:~# sudo dpkg --set-selections < list.txt
server1:~# sudo aptitude update
server1:~# sudo aptitude install

Further Reading:
http://www.psychocats.net/ubuntu/aptitude
http://www.mail-archive.com/debian-user@lists.debian.org/msg542099.html
http://wiki.debian.org/Aptitude