Search code examples
shellaptapt-get

How do I enter 'y' automatically to apt-get?


I'm trying to automate a server setup using a shell script.

I need to install a few dependencies with apt-get and some require the user to input y before the install continues.

My question is how do I make sure the shell script automatically inserts y every time it sees something like Do you want to continue [Y/n]? ?

I've tried sudo apt-get install git << 'y' and 'y' | sudo apt-get install git but with no results.

What could I try next?


Solution

  • Just use the -y or --yes flag as described in the apt-getman pages.

    BTW there is even an option to --force-yes. So you got plenty of options at your hands.