1

So I am writing a script that changes various aspects of an Ubuntu 16.04.4 machine and one of the tasks is upgrading all packages. To do this I useapt-get -y upgrade. (-y for auto yes on dialogue and provide automation) This works fine and is automated for nearly all packages but once every so often I will get the interaction pane depicted below.

I'm assuming there is no easy way to handle and answer these dialogues in a uniform way across all packages but is there a way to disable such an interaction and provide a truly automated, interaction-free upgrade?

David Foerster
  • 36,264
  • 56
  • 94
  • 147
  • I do get that but I am deploying this script under the precondition that no user is ever going to be interacting with the output so that -y flag is necessary frankly what I desire ~90% of the time. – Jake Lawrence May 30 '18 at 17:44

1 Answers1

3

You can do a couple of things for avoiding this. Setting the DEBIAN_FRONTEND variable to noninteractive and using -y flag. For example:

export DEBIAN_FRONTEND=noninteractive
apt-get -yq install [packagename]

If you need to install it via sudo, use:

sudo DEBIAN_FRONTEND=noninteractive apt-get -yq install [packagename]

(source)

David Foerster
  • 36,264
  • 56
  • 94
  • 147
  • Welcome to Ask Ubuntu! There's another and more important reason to include the relevant parts of linked resources than convenience in line: the linked resource may change or vanish in a way that invalidates the answer. Link-only answers are discouraged and usually deleted in review for that reason on Stack Exchange. – David Foerster May 30 '18 at 19:02