> ## Content Index
> Fetch the complete content index at: https://www.bagz.fr/llms.txt
> Use this file to discover other available public pages before exploring further.

# Automate apt update and keep current config files
- URL: https://www.bagz.fr/automate-apt-update-and-keep-current-config-files/
- Published: 2018-07-25T11:24:59.000Z
- Updated: 2018-07-25T11:24:59.000Z
- Author: bgazui
- Tags: Linux, #Migrated-1790668826633, #wp, #wp-post, #Import 2026-09-29 08:00

When doing update on a Debian/Ubuntu server, if a package is trying to modify a config file, it's asking for a manual choice. If you're trying to try to automate the process, you'd probably like to get rid of that ask and keep the current config file by default.

For that, you can use that script:

#!/bin/bash  
apt-get update  
listUpgrades=\`apt list --upgradable |grep upgradable |cut -d/ -f1\`  
execUpgrades="DEBIAN\_FRONTEND=noninteractive apt-get --yes --assume-yes -o DPkg::options::=\\"--force-confdef\\" -o DPkg::options::=\\"--force-confold\\" --only-upgrade install "$listUpgrades  
eval $execUpgrades  

The multiple options will enforce the update to keep current config and not overwrite it with the package default one.