PackagesThis in-depth technical tutorial will work for any Debian based system, but is written specifically for Ubuntu.

I’ve recently had the occasion to make a complete list of software installed on one of my Ubuntu boxes, and then reinstall it from scratch. Here’s a quick and easy way to generate a list of installed .deb packages, and then use that list to quickly reinstall them.

First, let’s make the list. You’ll be doing all of this in a Terminal Session:
dpkg –get-selections | grep -v deinstall > ubuntu-files
NOTE: WordPress interprets two dashes (- -) as one dash (–). When you’re putting this into your CLI, make sure it’s dropping two dashes ‘- -’ without the space between them.

Now you’ve got a list of all of your installed debs in a fairly small file. In my case, I simply moved this file to a thumb-drive. You could also store it on a separate partition or on a disk somewhere. Heck, it’s not that big, email it to your gmail account.

So now you’ve got this list and all is well, until you’re Ubuntu install either dies or has to be reinstalled for some reason. Go ahead and do the base install.

Once you’ve got Ubuntu back up and running, copy your ubuntu-files back into your home directory and do the following:
sudo apt-get update
sudo apt-get dist-upgrade
dpkg –set-selections < ubuntu-files

NOTE: WordPress interprets two dashes (- -) as one dash (–). When you’re putting this into your CLI, make sure it’s dropping two dashes ‘- -’ without the space between them.

Now you’ve told your system what it needs to install, so let’s install it all.
sudo dselect
This will open up a dselect session. Type ‘I‘ and allow dselect to install of the the packages listed in your ubuntu-files document. When it’s finished, type ‘Q‘ and hit the ENTER key to exit dselect.

Now you’re a lot closer to where you were before.

EDIT: As my friend fak3r points out, you can modify the fist dpkg command line to have it mail yourself the list after creatoin. Like so:

dpkg –get-selections | grep -v deinstall > ubuntu-files; cat ubuntu-files | mailx -s “ubuntu-files” my.mail@my.address

Share