apt-config 可以修改 apt 配置吗?

pan*_*.de 7 apt

我尝试使用 apt-config 更改 apt 配置值,但没有成功:

apt-config -o APT::Periodic::Unattended-Upgrade=1 shell
Run Code Online (Sandbox Code Playgroud)

Debian / Ubuntu 上是否有另一个程序可以自定义配置?

Oli*_*Oli 5

不,apt-config是只读的(正如它--help会告诉你的那样):

 apt-config is a simple tool to read the APT config file
Run Code Online (Sandbox Code Playgroud)

要保留 Apt 配置更改,您需要编辑/添加到/etc/apt/apt.conf.d/. 在开始创建新文件之前,您可能需要检查该变量是否已设置。这是寻找“Periodic”的快速 grep:

$ grep -R Periodic /etc/apt/apt.conf.d/
/etc/apt/apt.conf.d/10periodic:APT::Periodic::Update-Package-Lists "1";
/etc/apt/apt.conf.d/10periodic:APT::Periodic::Download-Upgradeable-Packages "1";
/etc/apt/apt.conf.d/10periodic:APT::Periodic::AutocleanInterval "0";
/etc/apt/apt.conf.d/10periodic:APT::Periodic::Unattended-Upgrade "1";
Run Code Online (Sandbox Code Playgroud)

这可能与您的计算机不同,因此请运行它。如果我要做出任何改变,我会跑步sudoedit /etc/apt/apt.conf.d/10periodic。Apt 应该在下次运行其命令之一时拾取这些内容。


注意:上面的内容显然适用于 apt.config 方面。/etc/apt/如果您尝试设置其他内容,(上面的父目录)中潜伏着其他设置,这些设置可能适用。

  • `apt-config --help` 并没有告诉它是只读的(apt 1.2.29)。 (2认同)