Automatically answer 'Yes' when using apt-get install

via the apt-get man page:

apt-get -y install [packagename]

The problem with:

apt-get --yes install $something

is that it will ask for a manual confirmation if the package signature owner's public-key is not in the keyring, or some other conditions. to be sure it does not ask a confirmation just do this:

apt-get --yes --force-yes install $something

If you want to have these settings permanent, create a file in /etc/apt/apt.conf.d/, like /etc/apt/apt.conf.d/90forceyes with the following content:

APT::Get::Assume-Yes "true";
APT::Get::force-yes "true";

Note that if you also want to automatically go by the default answers when an interactive prompt appears, you can use DEBIAN_FRONTEND=noninteractive

Single install:

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


sudo DEBIAN_FRONTEND=noninteractive apt-get -y install postfix

All updates:

sudo DEBIAN_FRONTEND=noninteractive apt-get -y update 

You can set up finer options with -o Dpkg::Options::="--force-confdef" and -o Dpkg::Options::="--force-confold".


apt-get update
sudo DEBIAN_FRONTEND=noninteractive apt-get upgrade -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold"


apt-get -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" dist-upgrade

Example of interactive prompt:

enter image description here

Interesting read: Perform an unattended installation of a Debian package