从命令行指定 APT 代理

tsh*_*ang 4 apt apt-cacher

有没有一种方法可以指定 APT 代理而无需使用文件(例如 apt.conf)?

tsh*_*ang 6

apt.conf接受的任何选项都可以在命令行上使用 指定--option。APT 代理的示例,假设apt-cacher-ng

apt update --option Acquire::HTTP::Proxy=http://localhost:3142
Run Code Online (Sandbox Code Playgroud)

与/etc/apt/apt.conf中的内容等效:

Acquire::HTTP::Proxy "http://localhost:3142";
Run Code Online (Sandbox Code Playgroud)