Debian packages – list and install on another server.

To list all currently installed packages, type “dpkg –get-selections”. You can save this data to a file by running “dpkg --get-selections > ~/packages.txt“.
And then place this file on another system and install the listed packages by running “cat packages.txt > sudo dpkg --set-selections && sudo apt-get dselect-upgrade“.
Also, the list of packages can be loaded for installation by running “dpkg --clear-selections && sudo dpkg --set-selections < packages.txt".
This could be used also for recovery. This trick is helpful when a system must be reinstalled, then all of the same packages can be installed all at once.
Sometimes, the output of "dpkg --get-selections" may list packages marked to be uninstalled or some other status. If so happens, use the following "dpkg --get-selections | grep -w install$ > ~/packages.txt". I mean, "| grep -w install$"

Leave a Reply

Your email address will not be published. Required fields are marked *

*