Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
up vote 32 down vote accepted

I believe this is self-explanatory:

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


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 {
share|improve this answer
Thanks a bunch, exactly what I was looking for. – 0xC0000022L Feb 17 '12 at 0:55
"I believe this is self-explanatory" ... proceeds to use options I've never seen anyone use for apt-get – notbad.jpeg Jun 10 '15 at 13:42
@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 – 0xC0000022L Nov 16 '15 at 8:46

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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