Automatically answer 'Yes' when using apt-get install


Is there a way to make apt-get install answer "yes" to the "Do you want to continue [y/N]?"?

19
задан Mistiry
13.11.2022 18:12 Количество просмотров материала 3004
Распечатать страницу

10 ответов

via the apt-get man page:

apt-get -y install [packagename]
351
отвечен jrc03c 2022-11-15 02:00

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";
159
отвечен bclermont 2022-11-15 04:17

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:

enter image description here

Interesting read: Perform an unattended installation of a Debian package

42
отвечен Franck Dernoncourt 2022-11-15 06:34
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.

15
отвечен Ajax4Hire 2022-11-15 08:51

From the apt-get HOWTO

Use the -y switch: apt-get -y install packagename

9
отвечен Powerlord 2022-11-15 11:08
apt-get -y update
apt-get -y install [package]
7
отвечен steve.lippert 2022-11-15 13:25

generally the options from the manual should work well

apt-get -y --force-yes install package

if it does not succeed you can try to use the yes command.

yes | apt-get -y --force-yes install package

did use this with my vagrant shell provisioning script

PS: in case you want non-interactive but with generally stating no then you can try this:

yes no | apt-get install package
2
отвечен Summer-Sky 2022-11-15 15:42

I was looking for a way to select a non-default in a script, specifically when installing wireshark, and ended up using tmux to interact with a shell, as follows:

# Start a detached root session
sudo tmux new-session -d
# Send the command
sudo tmux send-keys "DEBIAN_FRONTEND=readline apt-get -qq install wireshark-common; exit" enter
# Wait for the tmux session to get to the interactive stage
sleep 5
# Answer the question
sudo tmux send-keys "yes" enter
# Now attach to the session so we wait for command completion
sudo tmux attach
1
отвечен Stephen Ramm 2022-11-15 17:59

The new (well) apt alias takes the -y (--yes) switch too:

sudo apt -y upgrade
0
отвечен yPhil 2022-11-15 20:16

If you always want the -y argument I'd advise adding the line

alias apt-get='apt-get -y' #Automatic -y argument on apt-get commands

into your .bashrc. This, as the comment explains, will automatically add the -y argument to all your apt-get commands and therefore approves all the downloads.


NOTE: This will remain true until you revert your .bashrc and restart the shell.

0
отвечен Joseph Stevens 2022-11-15 22:33

Постоянная ссылка на данную страницу: [ Скопировать ссылку | Сгенерировать QR-код ]

Ваш ответ

Опубликуйте как Гость или авторизуйтесь

Имя
Вверх