Last week, we learned to get rid of third-party packages, now we’re going one step further: we’ll verify if the files of the installed packages are still exactly like they were when they got installed.
If you’re a tinkerer and hand-edit some files for some quick tests, or if you tend to re-install newer versions of some packages from the sources, you might have overwritten some packaged files and it would be good to be able to detect this (and remedy to the problem). debsums is the tool that makes it possible.
Use debsums to identify modified files
I often use debsums when I take over the maintenance of a Debian server because I want to verify which files have been modified by the former administrator.
Without any argument, debsums is very verbose, it will list every installed file (except configuration files) and tells whether it’s unmodified (“OK”) or not (“FAILED”).
$ sudo debsums /usr/bin/a2ps OK [...]
--all option, it will verify all files including configuration files. With
--config it will verify only the configuration files.
--changed option, debsums will only list modified files among those inspected. The following invocation will thus list all files which have been modified on the system and which are not configuration files.
$ sudo debsums --changed /usr/lib/perl5/AptPkg/Config.pm /usr/lib/perl5/AptPkg.pm [...]
Find out the package affected and reinstall it
debsums told me that
/usr/lib/perl5/AptPkg.pm was modified. Indeed I remember having manually installed a modified version of that perl module for a quick test.
I find out the affected package with
dpkg --search /usr/lib/perl5/AptPkg.pm: it’s libapt-pkg-perl.
Now I just have to reinstall this package to overwrite the modified files with the original ones:
$ sudo aptitude reinstall libapt-pkg-perl [...] # Or with apt-get $ sudo apt-get --reinstall install libapt-pkg-perl [...]
You might have to repeat the process until debsums no longer reports any modified file.
Do you want to read more tutorials like this one? Click here to subscribe to my free newsletter, you can opt to receive future articles by email.