The package system maintains a list of all packages installed (and de-installed). You can access this list, save it to a file, and use it to mark those same packages for installation (or deinstallation) on anther machine:
# dpkg --get-selections > dpkg-selections # dpkg --set-selections < dpkg-selections # apt-get dselect-upgrade