Answers:
sudo apt-get install -y whatever
在手册页(man apt-get
)中:
-y, --yes, --assume-yes
Automatic yes to prompts; assume "yes" as answer to all prompts and
run non-interactively. If an undesirable situation, such as
changing a held package, trying to install a unauthenticated
package or removing an essential package occurs then apt-get will
abort. Configuration Item: APT::Get::Assume-Yes.
对于apt-get -y
或--assume-yes
正常工作(如@rinzwind所述),我认为这是最好的答案。对于许多此类交互式管理操作,有一个类似的命令。
另一种通用的方法是:
$ echo "y" | sudo apt-get install edamame_biscuit
(如果edamame-biscuit是您要安装的(虚构)软件包,则假定“ y”是合法的响应;根据需要用“ yes”或其他文本替换。)
该方法的一个特点是,如果您错误地仅假设一个交互式提示,则此方法将中断。如果还有其他可能不需要的提示,您可能不想对它们说“是”,则可以避免让系统随便询问的情况。
yes | sudo apt-get install edamame-biscuit
。是的命令会向其输出发送“ yes”一词。您还可以根据需要使其输出其他任何文本,请参见联机帮助页。
yes
命令(默认情况下)仅输出字母,y
后跟换行以填充管道缓冲区所需的次数。要实际打印单词yes
,必须使用命令yes yes
。
yes
,请原谅我的错
首先,让我们了解为什么出现此消息。实际上,如果该软件包没有尚未安装的依赖项,或者没有明确告诉您要安装的依赖项,则apt永远不会询问您:
➜ ~ sudo apt-get -qq install xfce4-screenshooter
Selecting previously unselected package xfce4-screenshooter.
(Reading database ... 296146 files and directories currently installed.)
Preparing to unpack .../xfce4-screenshooter_1.8.1-2_amd64.deb ...
Unpacking xfce4-screenshooter (1.8.1-2) ...
Processing triggers for hicolor-icon-theme (0.13-1) ...
Processing triggers for man-db (2.6.7.1-1) ...
Processing triggers for gnome-menus (3.13.3-1) ...
Processing triggers for desktop-file-utils (0.22-1) ...
Processing triggers for mime-support (3.56) ...
Setting up xfce4-screenshooter (1.8.1-2) ...
如果要安装依赖于软件包的软件包,则没有提到,它会询问:
➜ ~ sudo apt-get -q install avis
Reading package lists...
Building dependency tree...
Reading state information...
The following extra packages will be installed:
libjzlib-java libmina-java libslf4j-java
Suggested packages:
libmina-java-doc libspring-beans-java libcommons-logging-java
liblog4j1.2-java
The following NEW packages will be installed:
avis libjzlib-java libmina-java libslf4j-java
0 upgraded, 4 newly installed, 0 to remove and 14 not upgraded.
Need to get 720 kB of archives.
After this operation, 1,258 kB of additional disk space will be used.
Do you want to continue? [Y/n]
即使这样,也不会问您是否还隐式地说要安装那些软件包:
➜ ~ apt-get -q install avis libjzlib-java libmina-java libslf4j-java
Reading package lists...
Building dependency tree...
Reading state information...
Suggested packages:
libmina-java-doc libspring-beans-java libcommons-logging-java
liblog4j1.2-java
The following NEW packages will be installed:
avis libjzlib-java libmina-java libslf4j-java
0 upgraded, 4 newly installed, 0 to remove and 14 not upgraded.
Inst libjzlib-java (1.1.3-1 Debian:testing [all])
Inst libslf4j-java (1.7.7-1 Debian:testing [all])
Inst libmina-java (1.1.7.dfsg-11 Debian:testing [all])
Inst avis (1.2.2-2 Debian:testing [all])
Conf libjzlib-java (1.1.3-1 Debian:testing [all])
Conf libslf4j-java (1.7.7-1 Debian:testing [all])
Conf libmina-java (1.1.7.dfsg-11 Debian:testing [all])
Conf avis (1.2.2-2 Debian:testing [all])
但是,那么,如何使其不明确地要求您呢?通过Rizwind,答案应涵盖即席和脚本解决方案(实际上,该选项在脚本中使用更多),您可以改为修改apt.conf
文件并添加:
APT::Get::Assume-Yes
像这样的东西就足够了:
echo 'APT::Get::Assume-Yes;' | sudo tee -a /etc/apt/apt.conf.d/00Do-not-ask
请注意,这将不允许您验证其他更严重的提示,例如:
➜ ~ sudo apt-get install sonar
WARNING: The following packages cannot be authenticated!
sonar
Install these packages without verification? [y/N]
这就是为什么我不建议使用的原因yes | ...
,因为此警告将被忽略。
python:3.6-slim
)。我是否应该为此提出一个单独的问题?