Site icon New Generation Enterprise Linux

Stop apt from nuking your config files during an upgrade

Package Management (Apt/Dnf/Pacman Internals)

Stop apt from nuking your config files during an upgrade

đź§© The Challenge

You know that feeling when you update a web server and apt silently overwrites your custom nginx or apache config with the default one, effectively nuking your site? I’ve spent way too many mornings drinking cold coffee while trying to recover my settings from a backup.

đź’ˇ The Fix

Tell apt to be paranoid about changes to configuration files so it prompts you instead of just blindly overwriting your work. This saves you from the nightmare of merging complex changes manually after a simple update.

apt-get -o Dpkg::Options::="--force-confold" upgrade

⚙️ Why It Works

By passing the force-confold option, you’re telling the package manager to keep your existing modified configuration files by default whenever a conflict is detected. It avoids the dreaded replace-or-keep prompt that usually results in the system overwriting your hard work if you aren’t paying attention.

🚀 Pro-Tip: Use –force-confdef if you want it to automatically choose the package maintainer’s version for files you haven’t touched, while still keeping yours for the ones you have.

Linux Tips & Tricks | © ngelinux.com | 10/4/2026

0 0 votes
Article Rating
Exit mobile version