Record Installed .deb Packages In A Text File (Ubuntu/Debian)

Version 1.0
Author: Falko Timme

This short guide shows two methods of recording all your installed .deb packages in a text file that you can then use on another computer to install the same packages there. This is useful if you want to install the same set of packages on more than one computer.

I do not issue any guarantee that this will work for you!


1 Preliminary Note

I will show how to do this on the desktop (with Synaptic) and on the command line. I'm using a USB stick to store the text file; that way I can simply plug in the USB stick with the text file into the other computer and start the package installation there.

If you try this, please make sure the the file /etc/apt/sources.list is identical on both systems (if you like, you can also copy that file to the USB stick so that it can be used on the other computer).


2 Synaptic Package Manager

This chapter shows how you can create the package file with the Synaptic Package Manager. Open the Synaptic Package Manager (System > Administration > Synaptic Package Manager):

Then go to File > Save Markings or File > Save Markings As...:

Type in a name for the file (e.g. my_packages.txt) and check Save full state, not only changes (otherwise it would save only the changes that you've made in the current Synaptic session). Select your USB stick to save the file (my USB stick is named disk):

That's it. Now plug the USB stick into the other computer, open Synaptic, and go to File > Read Markings...:

Select the my_packages.txt file from the USB stick:

Afterwards, you should notice that some packages are marked (the ones that are installed on the first system, but not on this one). Click on Apply to start the installation:


3 Command Line

This chapter shows how you can create the package file on the command line. Open a terminal (Applications > Accessories > Terminal) and type:

sudo dpkg --get-selections "*" > /media/disk/my_packages.txt

(I'm assuming that /media/disk is your USB stick.)

Now plug the USB stick into the other computer, open a terminal there and run...

sudo dpkg --set-selections < /media/disk/my_packages.txt
sudo apt-get -u dselect-upgrade

... to start the package installation (I'm assuming that the USB stick's mount point on the second computer is /media/disk again).


Share this page:

Suggested articles

7 Comment(s)

Add comment


By: Marcus

Using dpkg --[get|set]-selections will miss the information on which packages were installed manually and which were installed automatically to satisfy dependencies. So on the target machine those packages that were installed automatically won't be removed when they are no longer needed. To keep the information about auto-installed packages instead of dpkg --get-selections one should use aptitude-create-state-bundle(1). On the target machine simply run aptitude-run-state-bundle(1) instead of dpkg --set-selections. Just my €0.02 ;) Cheers Marcus


Did you check Save full state, not only changes?

By: treb0r

Same problem here. Synaptic just saves an empty file. Any ideas?

By: Anonymous

Thanks for the post.

On the target system it probably would be a good idea to run
sudo dpkg --clear-selections
before dpkg --set-selections.  According to the man-page this makes sure that no packages installed on the target and not on the source are set to be removed when running the apt-get command.

By: hippie

I get an empty text file.

By: Alejandro

Very useful post.

Anyway, I think you should aware  that this method only works well if you use the same Ubuntu version on both computers.

This applies not only to the release  (i.e. 8.10), but also to the type of installation (server or desktop) and the hardware architecture (Intel 32 bit, AMD 64 bit...)

Great and useful post, as always


By: johan

This is very helpfull, but sometimes you whant versions also, you whant to duplicate a machine and avoid updates which could cause problem for your usage. I have a solution for it.

echo -n "apt-get -s install" >
dpkg-query -W -f=' ${Package}=${Version}'>>
chmod 700

echo -n "apt-get install" >
dpkg-query -W -f=' ${Package}=${Version}'>>
chmod 700