添加-y到任何库安装

添加-y到任何库安装

当然,当你输入:

sudo apt-get install whatever

它会询问你:

Do you want to continue [Y/n]? 

有什么方法可以让我直接安装而不询问我是否要继续?我不太在乎空间,我有足够的空间。

答案1

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.

答案2

对于 apt-get,-y或者--assume-yes工作得很好(正如@rinzwind 解释的那样),我认为这是最好的答案。对于许多这样的交互式管理操作,有一个类似的命令。

另一种非常通用的方法是:

 $ echo "y" | sudo apt-get install edamame_biscuit

(其中 edamame-biscuit 是您想要安装的(虚构的)包,并且“y”被认为是合法的响应;根据需要用“yes”或其他文本替换。)

此方法的一个“特点”是,如果您错误地假设只有一个交互提示,此方法就会中断。如果还有一些您可能不想回答的潜在不需要的提示,则可以避免系统不经询问就继续运行的情况。

答案3

首先,让我们了解一下为什么出现该消息。

如果软件包没有您未安装的依赖项,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 | ...,因为这个警告会被忽略。

答案4

添加-y到任何库安装

例如sudo apt-get install -y nodejs

例如sudo apt-get install -y postgres

例如sudo apt-get install -y mongodb




--force-yes as well,并小心意外空间。 近期发行版已贬值

相关内容