I'd like to output a list of all installed packages into a text file so that I can review it and bulk-install on another system. How would I do this?
I'd like to output a list of all installed packages into a text file so that I can review it and bulk-install on another system. How would I do this?
Ubuntu 14.04 and above
The
apt
tool on Ubuntu 14.04 and above makes this very easy.Older Versions
To get a list of packages installed locally do this in your terminal:
(The
-v
tag "inverts" grep to return non-matching lines)To get a list of a specific package installed:
To save that list to a text file called
packages
on your desktop do this in your terminal:Alternatively, simply use
(you don't need to run any of these commands as the superuser, so no
sudo
or any other variants necessary here)To get just the packages which were expressly installed (not just installed as dependencies), you can run
This will also include a brief description, which you may want. If not, also add the option
-F '%p'
, as mentioned by karthick87.Yet another option seems to be to copy the file
/var/lib/apt/extended_states
, which is a text file database in this format:Auto-Installed: 0
indicates that the package was expressly installed and is not just a dependency.To list all packages intentionally installed (not as dependencies) by apt commands, run the following :
This provides a reverse time based view, with older commands listed first:
Installation data also showing synaptic usage, but without details (the same with installation date) :
providing the following:
Create a backup of what packages are currently installed:
Then (on another system) restore installations from that list:
To get rid of stale packages:
To get installed like at backup time (i.e. to install packages set by
dpkg --set-selections
):man pages state:
So, it should just give a list of explicitly installed packages (though this includes packages that were part of the default initial install) without all of the dependencies included due to these packages being installed.
To output the result into a text file:
dpkg-query
(instead ofdpkg --get-selections
, which lists some packages that are not installed) as follows:Or:
To list all installed packages,
or
or
Note:
You will get the result 1.txt file in your home folder or you can specify your own path.
APT-Clone
APT-Clone is used by
ubiquity
(Ubuntu installer) for upgrade process. It is much better than thedpkg --get-selections
solution because:How to Use
Install
Make backup
Restore backup
Restore to newer release:
Result structure
It makes a simple gzipped tar file which can be easily edited and reviewed before restoring on the other machines. Here an example of its structure:
I recommend using blueprint. Even though it is designed for servers, it can be also used from desktops as well. It will create a shell script/chef/puppet that you ca use to re-install all you packages.
You can use Synaptic to save the current state of your installed packaged. In Synaptic, select "file/save markings", Enter the name of the file to save the state to, and make sure to check the "Save full state, not only changes" box.
The file saved from this can be loaded into a new machine using "file/read markings" in Synaptic.