Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

apt-get update non interactive

Tags:

ubuntu

apt-get

I'm trying to make an update fully non interactive.(on ubuntu 14.04.3 LTS) I thought it will be easy with this type of command:

export DEBIAN_FRONTEND=noninteractive
apt-get update && apt-get upgrade -q -y --force-yes && apt-get dist-upgrade -q -y --force-yes

but no... I always have a question like:

Configuration file '/etc/cloud/cloud.cfg'
 ==> Modified (by you or by a script) since installation.
 ==> Package distributor has shipped an updated version.
   What would you like to do about it ?  Your options are:
    Y or I  : install the package maintainer's version
    N or O  : keep your currently-installed version
      D     : show the differences between the versions
      Z     : start a shell to examine the situation
 The default action is to keep your current version.
*** cloud.cfg (Y/I/N/O/D/Z) [default=N] ?

So do you known how I can accept the default value automatically ?

like image 935
David Avatar asked Oct 27 '15 14:10

David


People also ask

What does Debian_frontend noninteractive mean?

noninteractive – You use this mode when you need zero interaction while installing or upgrading the system via apt. It accepts the default answer for all questions. It might mail an error message to the root user, but that's it all. Otherwise, it is totally silent and humble, a perfect frontend for automatic installs.

What is Debian_frontend?

With debconf/priority=critical , the installation system will display only critical messages and try to do the right thing without fuss. DEBIAN_FRONTEND. This boot parameter controls the type of user interface used for the installer. The current possible parameter settings are: DEBIAN_FRONTEND=noninteractive.


2 Answers

>= Apt 1.1

If you're using Apt 1.1 or above, --force-yes has been deprecated, so you've to use the options starting with --allow instead, e.g. --allow-downgrades, --allow-remove-essential, --allow-change-held-packages.

So the command is:

DEBIAN_FRONTEND=noninteractive \
  apt-get \
  -o Dpkg::Options::=--force-confold \
  -o Dpkg::Options::=--force-confdef \
  -y --allow-downgrades --allow-remove-essential --allow-change-held-packages

Note: Use --force-confold to keep old, and --force-confnew to keep new configs.

Source: CFE-2360: Make apt_get package module version aware.

Related:

  • 100% non-interactive Debian dist-upgrade
  • How do I ask apt-get to skip any interactive post-install configuration steps?
  • Non-interactive apt upgrade
like image 162
kenorb Avatar answered Sep 24 '22 21:09

kenorb


You need to pass some dpkg options to your commands, for instance:

export DEBIAN_FRONTEND=noninteractive
apt-get update && 
    apt-get -o Dpkg::Options::="--force-confold" upgrade -q -y --force-yes &&
    apt-get -o Dpkg::Options::="--force-confold" dist-upgrade -q -y --force-yes

On a side note, I would recommend using only dist-upgrade, you will eventually end up with broken dependencies if you use upgrade.

like image 40
ryanpcmcquen Avatar answered Sep 21 '22 21:09

ryanpcmcquen