Automatically answer 'Yes' when using apt-get install
Solution 1:
via the apt-get man page:
apt-get -y install [packagename]
Solution 2:
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";
Solution 3:
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]
E.g.:
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"
.
Examples:
apt-get update
sudo DEBIAN_FRONTEND=noninteractive apt-get upgrade -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold"
or
apt-get -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" dist-upgrade
Example of interactive prompt:
Interesting read: Perform an unattended installation of a Debian package
Solution 4:
APT::Get::Assume-Yes "true";
APT::Get::force-yes "true";
This should at least be in /etc/apt/apt.conf
and commented out. I worry Ubuntu is taking the Microsoft tack of always asking for permission.
"Are you sure?", of course I am sure, I am not a trained monkey simply typing away at the keyboard, going click happy.
Next the door will ask, "Are you sure you want to go outside?"
The oven will ask, "Are you sure you want to cook?"
The automobile will ask, "Are you sure you want to apply brakes?"
The fire extinguisher will ask, "Are you sure you want to put out the fire?"
I am sorry Dave, I can't let you do that.
HAL9000 could use a contraction but Data could not, or couldn't.
Solution 5:
From the apt-get HOWTO
Use the -y
switch:
apt-get -y install packagename