I would like to get a list of packages installed on one system and install all of them on another system.

I know that dpkg --get-selections can give me a list of all installed packages which I can pipe into dpkg --set-selections on the target system. However, some of the installed packages are ones that I built myself locally (using e.g. checkinstall) and are not available from the repositories. The dpkg --set-selections process will fail when it is unable to find these packages in the repositories.

So is there a way I can filter the list generated by dpkg --get-selections so that it only contains packages whose currently-installed version is available in my current repositories?


I believe Software Center has a feature for syncing between computers these days. If that handle missing packages correctly, it could solve your problem.

The issue here is that dpkg isn't aware of repositories, only installed packages. You can find out if a package is available in a repository by running apt-cache policy $package. If you see a repository in the Version Table, it's available there.

So, how about this?. It's slow, but should work:

dpkg --get-selections '*' \
  | while read line; do
    apt-cache policy $(echo "$line" | cut -f1 ) \
      | grep -q 'http://' \
      && echo "$line"
  • This will show the progress and write into a file: total=$(dpkg --get-selections '*'|wc -l); i=0; dpkg --get-selections '*' | while read line; do i=$(($i+1)); apt-cache policy $(echo "$line" | cut -f1 ) | grep -q 'http://' && echo "$i/$total $line"; echo $line>>/var/tmp/dpkg-selection.list; done
    – rubo77
    Jul 29 '19 at 20:18

Use the following command

dpkg --get-selections > installed-software

it will create a file called installed-software in your home directory

on the new system

dpkg --set-selections < installed-software

this will read the selection and install

  • 3
    I don't think you read the question. Apr 23 '12 at 15:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.