我正在尝试禁用代理,apt-get但似乎是apt-get从 以外的其他地方获取代理配置/etc/apt/apt.conf,因为尽管apt.conf文件为空(并且系统代理设置为None),但它仍在尝试连接到代理。
有人有想法吗?
Aha*_*ius 49
我正在使用脚本来替换不同的配置文件,以便在代理和非代理环境之间轻松切换。问题是我用一个空的 apt.conf 文件替换了代理 apt.conf 文件,然后 apt 忽略了该文件。
也适用于当前最新的 Ubuntu。
如果代理 conf 不存在,则创建它:
$ sudo touch /etc/apt/apt.conf.d/95proxy.conf
Run Code Online (Sandbox Code Playgroud)
然后添加以下两行:
Acquire::http::Proxy "false";
Acquire::https::Proxy "false";
Run Code Online (Sandbox Code Playgroud)
Ala*_*Ali 16
有时,仍然设置了代理环境变量。
要找出答案,请执行以下命令:
env | grep proxy
Run Code Online (Sandbox Code Playgroud)
如果您看到一些输出,例如:
http_proxy=http://127.0.0.1:1234/
Run Code Online (Sandbox Code Playgroud)
然后你需要取消设置这个变量。
为此,请执行以下命令:
unset http_proxy
Run Code Online (Sandbox Code Playgroud)
对所有其他条目(例如https_proxy.
Pra*_*nge 13
如果您不想apt-get使用代理,请使用apt-get:
sudo apt-get -o Acquire::http::proxy=false <update/install>
Run Code Online (Sandbox Code Playgroud)
apt-get 读取配置文件的地方不止一处。您应该运行grep -i proxy /etc/apt/apt.conf.d/*,它会给你一个具有代理服务器设置确切的文件(这只是与运行的例子update,而不是proxy:
grep -i update /etc/apt/apt.conf.d/*
/etc/apt/apt.conf.d/20apt-show-versions:// When Apt's cache is updated (i.e. apt-cache update)
/etc/apt/apt.conf.d/20packagekit:// Whenever dpkg is called we might have different updates
/etc/apt/apt.conf.d/20packagekit:// i.e. if an user removes a package that had an update
/etc/apt/apt.conf.d/20packagekit:"/usr/bin/test -e /usr/share/dbus-1/system-services/org.freedesktop.PackageKit.service && /usr/bin/test -S /var/run/dbus/system_bus_socket && /usr/bin/gdbus call --system --dest org.freedesktop.PackageKit --object-path /org/freedesktop/PackageKit --timeout 1 --method org.freedesktop.PackageKit.StateHasChanged cache-update > /dev/null; /bin/echo > /dev/null";
/etc/apt/apt.conf.d/20packagekit:// When Apt's cache is updated (i.e. apt-cache update)
/etc/apt/apt.conf.d/20packagekit:"/usr/bin/test -e /usr/share/dbus-1/system-services/org.freedesktop.PackageKit.service && /usr/bin/test -S /var/run/dbus/system_bus_socket && /usr/bin/gdbus call --system --dest org.freedesktop.PackageKit --object-path /org/freedesktop/PackageKit --timeout 1 --method org.freedesktop.PackageKit.StateHasChanged cache-update > /dev/null; /bin/echo > /dev/null";
Run Code Online (Sandbox Code Playgroud)