Sometimes you want to be able to install packages on another machine without the hassle of a long apt-get install command or having to write down every single package you’ve installed.
Luckily Debian has the wonderful dpkg which has 2 methods for generating a list of installed packages and another for importing a list.
Generating a list of installed packages
sudo dpkg --get-selections > selections
This will generate a file called selections which will contain something like
... snip ...
This is just a simple, plain text file so can be copied between servers.
Installing packages from an exported list
This is almost just as easy, first we need to actually set the list of selected packages
sudo dpkg --set-selections < selections
Then we need to actually do an update and install
sudo apt-get update && sudo …