How can I tell apt-get to install everything to the question “Do you want to continue [y/N]?”? How do I make apt-get install answer always “Yes” to apt-get in scripts?
You can force yes to prompts. In other words assume “yes” as answer to all prompts and run non-interactively.
Automatically answer “Yes” when using apt-get install command
The syntax is:
apt-get -y install foo apt-get -y remove bar apt-get --yes install htop apt-get --assume-yes foo
Force automatic “no” to all prompts for apt/apt-get command
Oppsite of above
apt-get --assume-no install pkg1 apt-get --assume-no --purge autoremove
We can do force yes too. However, this is a dangerous option that will cause apt/apt-get to continue without prompting if it is doing something potentially harmful. So I won’t recommend it until and unless you know what you are doing:
apt-get -y --force-yes install package1 apt-get -y --force-yes remove package2
apt-get DEBIAN_FRONTEND environment variable
We can 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. One can use such mode in Dockerfile, shell scripts, cloud-init script, and more.
export DEBIAN_FRONTEND=noninteractive apt-get -y update apt-get -y upgrade apt-get -y install bar