I have a server running Ubuntu and a program which was installed with apt-get install
and I'd like to see the unmodified config file (e.g. /etc/foo/foo.cfg
) so that I can diff it against the current version to see what modifications were made. Is there an easy way to do this, perhaps with some sort of apt command?
3 Answers
As far as I know you can only achieve this if you still have the original .deb around, but most of the time a similar one should be enough.
I think this superuser.com link answers this question more thoroughly than I could:
https://superuser.com/questions/69045/how-do-i-get-the-default-configuration-from-a-deb-file
apt-get
doesn't store the original version of the configuration file. You can redownload the original package.
As a preventative measure, install etckeeper Install etckeeper http://bit.ly/software-small, which is a seamless way of having version control in /etc
. Once you've installed the package, edit /etc/etckeeper/etckeeper.conf
to select your favorite version control software (the default is Bazaar, you can use Darcs, Git or Mercury instead), then run etckeeper init
. You won't have to interact with etckeeper
again unless you want to. You can run etckeeper commit
manually after you've made a change, but if you don't apt will automatically make a commit before and after each package installation run. Use the VCS's commands (log, diff, annotate, …) to look at change histories and revert to older versions.
I wrote the a script for this use case. The script will download the .deb
of a given package, and extract it's ./etc contents into the current working directory:
#!/usr/bin/env bash
set -eu
PACKAGE=${1:?"Package not provided"}
TMPDIR=$(mktemp --directory --tmpdir=/var/tmp "deb-etc-${PACKAGE}.XXXXXXX")
trap "rm -rf ${TMPDIR}" EXIT
pushd "${TMPDIR}"
apt download "${PACKAGE}"
ar -x *.deb
tar -xvf data.tar.xz ./etc/
popd
mv "${TMPDIR}/etc" "etc-${PACKAGE}"