首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >DEBIAN_FRONTEND环境变量

DEBIAN_FRONTEND环境变量
EN

Ask Ubuntu用户
提问于 2017-11-03 12:11:04
回答 2查看 65.6K关注 0票数 50

我的潜在主机提供商建议在终端中运行一个命令,以便使基于KVM的服务器的OS映像最小化。由于他们的KVM模板附带了我不需要的包,我想我可以使用相同的命令来删除不需要的包。

该命令以DEBIAN_FRONTEND=noninteractive开头,然后按以下方式调用apt-get remove

代码语言:javascript
复制
DEBIAN_FRONTEND=noninteractive apt-get remove --purge -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" package-1 package-2 ... package-n; apt-get -y autoremove; apt-get clean all 

这是我第一次遇到DEBIAN_FRONTEND环境变量,到目前为止我还没有找到有用的信息。因此,我想知道将其设置为noninteractive会产生什么效果,以及它是否可取,因为我认为该值(noninteractive)将持续存在。

EN

回答 2

Ask Ubuntu用户

回答已采纳

发布于 2017-11-03 13:00:00

简单地在apt命令前面加上DEBIAN_FRONTEND=something,不会在应用它的单个命令之后持久存在。

DEBIAN_FRONTEND选项记录在debconf的第7节手册页中(您可能需要安装debconf-doc包才能在您的系统上使用这些选项)。来自man 7 debconf

代码语言:javascript
复制
Frontends
   One of debconf's unique features is that the interface it  presents  to
   you is only one of many, that can be swapped in at will. There are many
   debconf frontends available:

   dialog The default frontend, this uses  the  whiptail(1)  or  dialog(1)
          programs to display questions to you. It works in text mode.

   readline
          The  most  traditional frontend, this looks quite similar to how
          Debian configuration always has been:  a  series  of  questions,
          printed  out  at  the console using plain text, and prompts done
          using the readline library. It even supports tab completion. The
          libterm-readline-gnu-perl package is strongly recommended if you
          chose to use this frontend; the default readline module does not
          support  prompting  with default values.  At the minimum, you'll
          need the perl-modules package installed to use this frontend.

          This frontend has some special hotkeys. Pageup (or ctrl-u)  will
          go  back  to  the previous question (if that is supported by the
          package that is using debconf), and pagedown  (or  ctrl-v)  will
          skip forward to the next question.

          This is the best frontend for remote admin work over a slow con‐
          nection, or for those who are comfortable with unix.

   noninteractive
          This is the anti-frontend. It never interacts with you  at  all,
          and  makes  the  default  answers  be used for all questions. It
          might mail error messages to root, but that's it;  otherwise  it
          is  completely  silent  and  unobtrusive, a perfect frontend for
          automatic installs. If you are using this front-end, and require
          non-default  answers  to questions, you will need to preseed the
          debconf database; see the section below  on  Unattended  Package
          Installation for more details.

委员会还注意到:

代码语言:javascript
复制
   You can change the default frontend debconf uses by reconfiguring  deb‐
   conf.  On the other hand, if you just want to change the frontend for a
   minute, you can set the DEBIAN_FRONTEND  environment  variable  to  the
   name of the frontend to use. For example:

     DEBIAN_FRONTEND=readline apt-get install slrn

   The  dpkg-reconfigure(8) and dpkg-preconfigure(8) commands also let you
   pass --frontend= to them, followed by the frontend  you  want  them  to
   use.

   Note  that not all frontends will work in all circumstances. If a fron‐
   tend fails to start up for some reason, debconf will print out  a  mes‐
   sage explaining why, and fall back to the next-most similar frontend.
票数 60
EN

Ask Ubuntu用户

发布于 2022-09-18 19:40:48

当编写无人参与的脚本(包括Dockerfile)时,当使用apt install -y但没有DEBIAN_FRONTEND=noninteractive时,有时安装会在交互式提示符下卡住。

通过使用DEBIAN_FRONTEND=noninteractive运行安装命令,将禁用这些交互式的x提示。

票数 9
EN
页面原文内容由Ask Ubuntu提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://askubuntu.com/questions/972516

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档