When running apt-get -y install <packages ...> on Ubuntu 10.04 I would like apt-get (or aptitude if that makes it easier) to not prompt me when installing additional dependencies (behavior of -y as I understand it) and but not prompt me about overwriting configuration files, instead assume to keep the existing ones always (which is usually the default). Unfortunately --trivial-only seems to be the inverse of -y and not affect the prompt that is shown, according to the man page.

In particular packages auch as samba, nullmailer, localepurge and lighttpd have forced me to interact with the terminal, even though the whole procedure was scripted and meant to be non-interactive.

1 Answer 1


You may use:

sudo apt-get update
sudo apt-get -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" dist-upgrade

For only specific packages, e.g. mypackage1 mypackage2:

sudo apt-get update
sudo apt-get -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" install mypackage1 mypackage2

Source: http://raphaelhertzog.com/2010/09/21/debian-conffile-configuration-file-managed-by-dpkg/

Avoiding the conffile prompt

Every time that dpkg must install a new conffile that you have modified
(and a removed file is only a particular case of a modified file in dpkg’s eyes),
it will stop the upgrade and wait your answer. This can be particularly annoying for
major upgrades. That’s why you can give predefined answers to dpkg with the help
of multiple --force-conf* options:

    --force-confold: do not modify the current configuration file, the new version
is installed with a .dpkg-dist suffix. With this option alone, even configuration
files that you have not modified are left untouched. You need to combine it with
--force-confdef to let dpkg overwrite configuration files that you have not modified.
    --force-confnew: always install the new version of the configuration file, the
current version is kept in a file with the .dpkg-old suffix.
    --force-confdef: ask dpkg to decide alone when it can and prompt otherwise. This
is the default behavior of dpkg and this option is mainly useful in combination with
    --force-confmiss: ask dpkg to install the configuration file if it’s currently
missing (for example because you have removed the file by mistake).

If you use Apt, you can pass options to dpkg with a command-line like this:

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

You can also make those options permanent by creating /etc/apt/apt.conf.d/local:

Dpkg::Options {

You can find more information and more options in the dpkg manual at http://manpages.ubuntu.com/manpages/xenial/en/man1/dpkg.1.html or man dpkg and i.e. look for "confdef".

  • 39
    "I believe this is self-explanatory" ... proceeds to use options I've never seen anyone use for apt-get Commented Jun 10, 2015 at 13:42
  • 2
    @notbad.jpeg: I believe the remark was aimed at the naming of those options. I find the names indeed self-explanatory. Of course knowing to use them wasn't :-D Commented Nov 16, 2015 at 8:46
  • 4
    what about -y ?
    – JDS
    Commented Jan 9, 2017 at 20:58
  • 4
    See also: linux.die.net/man/1/dpkg under the --force section, it describes the confold and confdef options. Also helpful: apt-config dump from askubuntu.com/questions/254129/…
    – thom_nic
    Commented Oct 16, 2017 at 14:55
  • 3
    "self-explanatory"... hmm, I found that description extremely confusing, especially whether to use them in combination or not. The one that cleared things up was dpkg(1). Thanks @thom_nic.
    – Lloeki
    Commented Nov 13, 2017 at 10:21

This site is temporarily in read-only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .