你可以使用:
sudo apt-get update
sudo apt-get -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" dist-upgrade
仅针对特定的软件包,例如mypackage1和mypackage2:
sudo apt-get update
sudo apt-get -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" install mypackage1 mypackage2
来源:
http://raphaelhertzog.com/2010/09/21/debian-conffile-configuration-file-managed-by-dpkg/
Avoiding the conffile prompt
Every time that dpkg must install a new conffile that you have modified
(and a removed file is only a particular case of a modified file in dpkg’s eyes),
it will stop the upgrade and wait your answer. This can be particularly annoying for
major upgrades. That’s why you can give predefined answers to dpkg with the help
of multiple --force-conf* options:
--force-confold: do not modify the current configuration file, the new version
is installed with a .dpkg-dist suffix. With this option alone, even configuration
files that you have not modified are left untouched. You need to combine it with
--force-confdef to let dpkg overwrite configuration files that you have not modified.
--force-confnew: always install the new version of the configuration file, the
current version is kept in a file with the .dpkg-old suffix.
--force-confdef: ask dpkg to decide alone when it can and prompt otherwise. This
is the default behavior of dpkg and this option is mainly useful in combination with
--force-confold.
--force-confmiss: ask dpkg to install the configuration file if it’s currently
missing (for example because you have removed the file by mistake).
If you use Apt, you can pass options to dpkg with a command-line like this:
$ apt-get -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" dist-upgrade
You can also make those options permanent by creating /etc/apt/apt.conf.d/local:
Dpkg::Options {
"--force-confdef";
"--force-confold";
}
你可以在dpkg手册的
http://manpages.ubuntu.com/manpages/xenial/en/man1/dpkg.1.html或者
man dpkg
中找到更多信息和更多选项,例如搜索"confdef"。
--force-confold
和--force-confnew
是互斥的。在某些情况下(我不太确定是什么情况),可能没有明确的默认操作可以执行,因此--force-confdef
不知道该怎么做。在这种情况下,选择--force-confold
。但是,默认情况下可以安装新的配置文件,我知道某个服务器曾经这样做过,因为一些选项是错误的(不安全),所以他们会覆盖您的文件,而不是让您使用错误的信息...(但是他们首先备份了文件)。 - Alexis Wilke-y
呢? - JDSdpkg(1)
。谢谢 @thom_nic。 - Lloekiconfold
和confdef
时,意思是:“覆盖未更改的配置文件(如果升级的软件包有新的配置文件),并保留已更改的配置文件。” - Johnny Utahh