Sometimes I’ll be working on two different systems, and something is working perfectly on server #1 but doesn’t work on server #2. It’s all because of some stupid overlooked package dependency, so sometimes I use this method to make sure both systems have the same exact packages installed.
Server #1 (where everything is working fine):
dpkg --get-selections > install.txt
scp that file to server #2 and then:
dpkg --set-selections < install.txt
apt-get -u dselect-upgrade
Now, server #2 will have all the packages that server #1 has.