Migrate installed packages to a new system

Say you get a new system at work and you want a clean install of everything on the new system that you have on your old one. It's actually quite simple.

Once you have a base install on the new box just copy over the /etc/apt/sources.list from the old system to the new one and then update the new system:

new_sys$ apt-get update && apt-get upgrade

then on the old system do the following:

old_sys$ dpkg --get-selection | grep -v deinstall > installed-packages.txt

Then you copy installed-packages.txt to the new system. Now all that's left is to install the packages on your new system:

new_sys$ dpkg --clear-selections
new_sys$ cat installed-pakcages.txt | dpkg --set-selections
new_sys$ apt-get dselect-upgrade