Suppose some package foo...

$ apt-get install foo

..installs a dpkg blessed conffile /etc/foo.conf (ie package maintainer version)

Now suppose after the package is installed /etc/foo.conf is modifed, perhaps to add a line.

We would now like to get a diff between the package maintainer version of foo.conf and the current one (to see what local configuration changes were made).

What's the easiest way to do this?

One way would be to install the package in a chroot jail and then diff it to the clean one. Is there an easier way?


After you have upgraded your packages, dpkg will save its new configuration file with a .dpkg-new suffix (if you chose to keep your own changes):

diff -u /etc/foo.conf /etc/foo.conf.dpkg-new

If you chose for overwriting your conffiles, it will be renamed and get a .dpkg-old suffix: diff -u /etc/foo.conf.dpkgold /etc/foo.conf

As tumbleweed said, you can also extract the .deb file. First you need to get the .deb file from somewhere and then you will be able to extract it. If you have not run apt-get clean before, you should have a .deb file already available in /var/cache/apt/archives/ which means that you can skip the apt-get download part and adjust the path for dpkg-deb -x accordingly.

apt-get download foo
dpkg-deb -x foo_<version>_<arch>.deb fs
diff -u fs/etc/foo.conf /etc/foo.conf

You could install etckeeper. It manages your /etc directory with a VCS, automatically committing before and after every time you use apt.

Or, you can extract the deb: dpkg-deb -x foo.deb foo, will dump its contents into the foo directory.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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