Thursday, May 22, 2008

Get a list of installed packages in Ubuntu for reinstallation on another system

Get a list of installed packages in Ubuntu for reinstallation on another system
Published on November 25, 2007 in GNU/Linux. Ubuntu.

How do you get a new Ubuntu (or Debian or any distro using dpkg) installation to quickly have a specific set of packages installed without scouring through the list of packages and selecting packages one by one? More specifically how do you get a new Ubuntu installation (the target system) to have the same packages as your current one (the source system)?

Solution

Step 1: Configure and enable one or more repositories on the target system so that all repositories available in the source system are available in the target system. This Ubuntu help article - Adding Repositories in Ubuntu” - has more info on how to do it. Remember to add any non-standard repositories (for e.g. Google repositories) in addition to the standard ones.

https://help.ubuntu.com/community/Repositories
/Ubuntu#head-a86dddc6826cec4a3847d8441b24051d07b8dc64

Step 2: Get a listing of the packages currently installed on the source system using the following command.

sudo dpkg --get-selections | cut -f1 > installed-packages.txt

Step 3: Use the following command to feed the list of packages into apt-get on the target system, wait for apt-get to download and install all the packages and voila! you are done.

cat installed-packages.txt | sudo xargs apt-get install

No comments:

Post a Comment