Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

My SSD crashed, and I can't find the output from dpkg --get-selections that I created recently. However, I could make a copy of the /var/backups/dpkg.status.0 file from the broken ssd. I feel like all the information, that dpkg --get-selections gave me is in there, but in the wron format. And I feel like, there must be a command, that allows to convert it (rather that writing a script myself). Question: What is that command?

share|improve this question
up vote 1 down vote accepted

Basically from what im thinking is that all applications in /var/backups/dpkg.status.0 have install ok installed line so you will only have to use this command to get same output of dpkg --get-selections: grep "Package" < /var/backups/dpkg.status.0 | awk '{print $2"\t\tinstall"}'. Check it.

share|improve this answer
perfect! I was expecting something that invokes dpkg, but this works fine. – nutty Feb 18 '13 at 20:58

First, you check where dpkg --get-selections is getting it's raw data from. If you suspect it's getting the data from /var, then you can further narrow down the results with a grep. Like this:

strace dpkg --get-selections 2>&1 | grep /var

That will produce the following result:

open("/var/lib/dpkg/updates/", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3
open("/var/lib/dpkg/available", O_RDONLY) = 3
open("/var/lib/dpkg/triggers//File", O_RDONLY) = 3
stat("/var/lib/dpkg/triggers/Unincorp", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0

Then, if you wonder where that dpkg backup file came from, you can search your cron files for mentions of dpkg:

 grep -R dpkg /etc/cron*

From that, you could figure out that /var/backup/dpkg.status.0 was first backed up and then rotated, based on /var/lib/dpkg/status.

Putting the above together, you get dpkg --get-selections to produce the report you want, by temporarily restoring your "dpkg status" file back to /var/lib/dpkg/status and then running dpkg --get-selections. It will now reference your backup data.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.