29

I am trying to make a bash script that automates the installation of several packages that I use on any ubuntu machine. I frequently create virtual machines either through Amazon AWS or Digital Ocean and would like to just run one script to install all the packages I use.

Some of the packages I would like to install are Emacs and Node.js

The normal way I install these would be to run apt-get install Emacs, and while doing this I am always prompted with a warning about how much space this app will take up and if I am sure I want to continue.

Is there a way to automate this process, from a script, and always say "yes" to these prompts?

Startec
  • 1,935

3 Answers3

50

From the OPTIONS section of man apt-get

-y, --yes, --assume-yes
    Automatic yes to prompts; assume "yes" as answer to all prompts and
    run non-interactively. If an undesirable situation, such as
    changing a held package, trying to install a unauthenticated
    package or removing an essential package occurs then apt-get will
    abort. Configuration Item: APT::Get::Assume-Yes.
steeldriver
  • 142,475
28

There is a unix command called

yes

Without options it outputs the string "y" repeatedly until killed.

To use it, simply pipe the result to the command where you need the confirmations:

yes | apt-get install ...

Read more in the Unix man pages or in the SO post The “yes” command.

WeSee
  • 381
1

You can add -y To any library install to answer yes

Eg : apt-get install -y nodejs

Eg : apt-get install -y gnupg

vijay
  • 131