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.
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
Blogposts
Test comment. Please ignore.