I want to revert a file in /etc/
back to its originally-installed form. I have edited the file since it was installed. How can I revert this config file? Apt is smart enough not to overwrite edited config files, so how do I tell it that I want it to do so?
For argument's sake, let's say that I want to revert the file /etc/foo.conf
from the package foo
.
Best Answer
The answer provided by Ryan Thomson was heading to the right way. Still it would not be able to do the job (The details reason is given below).
The correct (and easiest) way of doing so is using
-o
withapt
to pass dpkg option and forcedpkg
to ask you whether you want to retain the modified config files or the original ones. The command will be like this -This would ask you a question like
You have to press either Y or I to install package maintainer's original config file. You can even press D to see what the changes or start a root shell with Z option to fix yourself.
Note: After the replacement, you'll find your modified file as
at /etc/foo/foo.conf.dpkg-old
Why other options would not work?
Because the other options in dpkg doesn't work well. The options which deals with a package's config files are
--force-confmiss
--force-confnew
--force-confold
--force-confdef
--force-confmiss
would not work when package version doesn't change. From man-page--force-confmiss
works with missing conffiles. It too will fail when version didn't change. Quoting man-page--force-confold
will retain modified version only if the version is changed. For same package, it too will fail. Quoting man-page--force-confdef
will also fail because the default action is to retain older file (Indicated from the message shown with--force-confask
. It has line(Y/I/N/O/D/Z) [default=N]
which means retaining is default. See above). And if--force-confnew
is specified but version do not change, that too will not work. Quoting man-pageOnly
--force-confask
will work, because it will explicitly ask you the question even when the version is same. Quoting man-pageHope that will help.