When building a new system or reinstalling a system on another system it can be very useful to check to see what differences there are between the packages installed on each system.
The following command will list all the installed packages.
$ dpkg --get-selections
Assuming that we have a file called ‘packages.txt’ that contains a list of all the packages that were installed on you system in the past (or that are installed on a different machine) you can use this file to see what the differences are between the two configurations.
To see which packages are missing from your current configuration use:
$ dpkg --get-selections | sort | comm -1 -3 - <(sort packages.txt)
To see which packages have been added since you recorded which packages were installed use:
$ dpkg --get-selections | sort | comm -2 -3 - <(sort packages.txt)
In this case you can see that I’ve recently installed the additional packages required for gcc.