Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

How do I export a list of installed Debian packages on a system, and then install those same packages on a new system?

share|improve this question

3 Answers 3

up vote 12 down vote accepted

To backup:

sudo dpkg --get-selections > /tmp/dpkglist.txt

To Restore:

sudo dpkg --set-selections < /tmp/dpkglist.txt
sudo apt-get -y update
sudo apt-get dselect-upgrade

Also see this question for additional options and info:

I have the above running in a daily cronjob that checks the dpgklist into SVN as part of our server inventory. This will allow you to keep a reasonable accurate inventory of installed packages across your servers and its easy to do a quick side-by-side diff to see if a server is missing a particular package.

share|improve this answer

You can also use aptitude for the same. This preserves information about "automatically installed" packages that other methods do not.

Run following on the reference machine

aptitude search -F '%100p' '~i!~M' > package_list

copy package_list to the other machine and run

xargs aptitude --schedule-only install < package_list; aptitude install;
share|improve this answer
Just a minor note. According to the aptitude reference manual, the "package" field is "expandable" by default, so aptitude search -F '%p' '~i!~M' > package_list should also work fine. –  chronos Oct 17 '13 at 23:34

That's a good idea, and you might also set up one server with apt-proxy if you make a habit of this.

share|improve this answer
After playing around with several proxies for apt, I ended up deciding on apt-cacher-ng. apt-cacher-ng is very simple to setup and from several accounts it seems to be more robust than the original apt-proxy. Each person has their own favourite though. –  faultyserver Aug 20 '09 at 21:06
My vote is for approx, it's the only one that isn't some kind of insane. –  womble Aug 20 '09 at 23:08
Interesting... I've not actually tried any of the alternatives. –  user17642 Aug 21 '09 at 16:00

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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