I created a custom debian package which needs to replace certain configuration files like /etc/ssh/sshd.conf. If these files exist it does not replace them. What is the best way from a deb package to force overwrite these files (if it's possible without a question).


  • 1
    Using packages to distribute configuration files may seem a good initial approach to configuration management, but most of us found that using actual configuration management tooling is much better for the long term. – HBruijn Jun 27 '14 at 10:26

First: Don't do that. Configuration files are expected to belong to only one package. Better use some configuration management.

If you really want to do it anyway, you likely need to use dpkg-divert in the maintainer scripts (preinst, postrm, etc.) to rename the original configuration file. See the maintainer scripts of grml's grml-etc-core package for an example:

Once again: Despite dpkg-divert is used above (for a live CD) to "overwrite" conffiles, it's not expected to work that way either, so expect that it may fail under some obscure conditions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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