Ubuntu 通过提示自动执行apt get install dnsmasq

Ubuntu 通过提示自动执行apt get install dnsmasq,ubuntu,apt-get,dnsmasq,Ubuntu,Apt Get,Dnsmasq,我想自动安装dnsmasq,但当我apt获得install它时,它会提示我回答一个问题,因为已经存在/etc/dnsmasq.conf。就我而言,我不想更换它 我如何能够自动执行此操作,使其不会阻止我的apt get install等待用户输入 # apt-get install dnsmasq -y Reading package lists... Done Building dependency tree Reading state information... Done T

我想自动安装
dnsmasq
,但当我
apt获得install
它时,它会提示我回答一个问题,因为已经存在
/etc/dnsmasq.conf
。就我而言,我不想更换它

我如何能够自动执行此操作,使其不会阻止我的
apt get install
等待用户输入

# apt-get install dnsmasq -y

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  dnsmasq
0 upgraded, 1 newly installed, 0 to remove and 8 not upgraded.
Need to get 16.2 kB of archives.
After this operation, 73.7 kB of additional disk space will be used.
Get:1 http://ports.ubuntu.com/ubuntu-ports bionic/universe arm64 dnsmasq all 2.79-1 [16.2 kB]
Fetched 16.2 kB in 0s (37.2 kB/s)
Selecting previously unselected package dnsmasq.
(Reading database ... 24542 files and directories currently installed.)
Preparing to unpack .../dnsmasq_2.79-1_all.deb ...
Unpacking dnsmasq (2.79-1) ...
Setting up dnsmasq (2.79-1) ...

Configuration file '/etc/dnsmasq.conf'
 ==> File on system created by you or by a script.
 ==> File also in package provided by package maintainer.
   What would you like to do about it ?  Your options are:
    Y or I  : install the package maintainer's version
    N or O  : keep your currently-installed version
      D     : show the differences between the versions
      Z     : start a shell to examine the situation
 The default action is to keep your current version.
*** dnsmasq.conf (Y/I/N/O/D/Z) [default=N] ? 

您可以通过如下方式指定
dpkg
选项来自动执行此操作:

$apt get-o Dpkg::Options::=“--force confdef”-o Dpkg::Options::=“--force confold”安装dnsmasq-y

这将保留当前的配置文件

以下是信息来源:

为什么需要安装这么多次?您可能希望移动此文件并在安装后再次粘贴它。这可以在shell脚本中完成。它只安装了一次,但配置文件已经存在。我可以手动删除配置,但我想让它更健壮。可能的重复请参见