Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

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

I'm looking for a script that is run from a boot-CD doing the following for all files on a drive:

  1. find the debian-package a file is from (if possible)
  2. download and extract the debian-package
  3. generate md5sums for the installed file and the downloaded file
  4. list differences and files that weren't packaged

Is something like this readily available? (I don't trust the local deb-archive.)


share|improve this question
3 is done for you by the deb itself if I recall. I know #1 is possible with dpkg (too lazy to look it up right now, will post later) – Huckle May 27 '12 at 22:08
The md5sums for #3 are stored locally and could be compromised. So that's no real solution. – chris May 27 '12 at 22:27
For #4, do you mean [(list differences of files that were packaged) and (list files that weren't packaged)] or [(list differences of (files and those that were not packaged))]? – Huckle May 27 '12 at 22:47
Also, if you are on a boot disc then dpkg/apt would not be using the local caches and so they could actually be used for fetching md5 sums. The live environment would have to download all of the packages on the system to the ramdrive however – Huckle May 27 '12 at 22:49
Why not just sudo apt-get install --reinstall $(sudo dpkg -l) and go get some coffee? – Huckle May 27 '12 at 22:50

Part 1

sudo dpkg -S stdio.h
sudo dpkg -S stdio.h | cut -d ':' -f 1 > packages.list

source: section 5.2

Part 2

mkdir -p /tmp/archives/partial
apt-get -d -o dir::cache=/tmp -o Debug::NoLocking=1 install --reinstall  < packages.list

source: Comment from dpk on Alfonso Vila's answer

Part 3

Debs are Ar archives and can be manipulated with ar. MD5 hashes can be found using:

openssl dgst -md5 <filename>

-- I stopped here as this is where I found debsums which does all of what you want in one tidy package

sources: Wikipedia on Deb and Debsums ManPage

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.