How to install the same debian packages on another system

The approach is simple: generate a list of installed packages on Debian-based systems and install this list of packages on the new box. This approach is useful when you want to install the same packages on another fresh OS install for example.

1. To export the list of installed packages, proceed as follows:

dpkg --get-selections | grep -v deinstall > LIST_FILE

The file LIST_FILE is small so it can be emailed to yourself by using:

dpkg --get-selections | grep -v deinstall > LIST_FILE && cat LIST_FILE | mailx -s "`hostname -f`: Package list" ""

2. Once you’ve got your server up and running with a fresh base install

apt-get update
apt-get dist-upgrade

3. Move your LIST_FILE file into your home directory and run the following commands to recover the previous generated list:

dpkg --clear-selections
dpkg --set-selections < LIST_FILE

4. Install the packages

aptitude install

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.