Re: How to determine which config files I have changed
Florian Kulzer wrote:
>On Mon, Oct 16, 2006 at 19:32:34 +0100, Paul Cager wrote:
>> I would like to be able to create a list of all of the configuration
>> files I have changed / created since installation. Mainly to make it
>> easy if I wanted to rebuild my system from scratch.
>>
>> I can get a list of installed packages easily enough (dpkg-query).
>> I can use the cruft package to find files I have added to /etc (and
>> other places if necessary).
>>
>> But I'm not sure of the best way to generate a list of files I have
>> changed. I could use "dpkg --contents" for each package to get a list of
>> files in the package and compare timestamps/sizes. But this only works
>> if the ".deb" files are still in /var/cache/apt/archives. Is there a
>> better way, such as cached MD5 sums somewhere?
>The md5sums are in /var/lib/dpkg/info as "packagename.md5sums".
>"packagename.conffiles" (if present for packagename) lists all the
>configuration files; that might save you from calculating md5sums
>unnecessarily.
Unfortunately not all packages have a md5sums file. These packages can
be found by running:
# cd /var/lib/dpkg/packages
# for i in *.conffiles ; do
> [ ! -f $(basename $i .conffiles).md5sums ] && echo $(basename $i .conffiles)
> done
For all the rest that do have md5sums files, the script below can be
used to list all the installed conffiles that have a different MD5 to
its original. It lists all modified files with an M, and files with
an unknown MD5 with ?. I guess that cruft should give you the rest.
----
#!/bin/bash
cd /var/lib/dpkg/info
for n in *.conffiles ; do
pkg="${n%%.conffiles}"
m="$pkg.md5sums"
if [ -f "$m" ] ; then
sort "$n" | (
sort -k 2 "$m" | sed 's! !:/!' | join -t : -2 2 -o 2.1,0 /dev/fd/3 -
) 3</dev/fd/0 | tr : ' ' | while read s f ; do
[ -f "$f" ] && [ "$(md5sum "$f" | awk '{print $1}')" != "$s" ] && echo "M $f"
done
else
sed 's/^/? /' $n
fi
done
----
Reply to: