It can be useful to have a list of installed packages in Debian when using it on multiple PCs or importing it after a fresh install.
There is a quick way to do this directly from the Terminal by using the following command :
dpkg –get-selections > installedpackages.txt
This will export the list of all installed packages and store it in a text file named installedpkgs.txt.
This file can be opened using any text editor or the contents be viewed from Terminal using cat command :
cat installedpkgs.txt
It will have the names of all the installed packages and the status as install next to them.
You can keep this file and import it on other PCs that need the same list of packages to be installed or after a reinstall by the following command :
dpkg –set-selections < installedpackages.txt
You can also check if a specific package is installed or not by searching for it in this file provided it is updated :
If the list finds the name of package, it will display the same, otherwise there will be no output.
To check if this list is updated or not, simply compare the output with the dpkg repository.
So it’s a good practice to run the export command to update this list with all the recently installed packages before trying to import it on another PC which requires the same list or before a reinstall.
All done.