在我的 Windows 机器上,代理设置很简单:
Automatic Proxy setup:
Automatically detect settings : checked
在我的 Windows 机器上,我安装了一个 Linux 子系统 (Ubuntu)。我正在尝试执行sudo apt update
或sudo apt install ...
。显然,为了完成此操作,我需要填写/etc/apt/apt.conf
(此文件尚不存在)。
我创建了该文件并且非常天真地输入了以下内容:
Linux Prompt> cat apt.conf
Acquire::http::proxy "http://<proxy>";
Acquire::https::proxy "https://<proxy>";
Acquire::ftp::proxy "ftp://<proxy>";
Acquire::socks::proxy "socks:<proxy>";
显然,这是行不通的,而且我不知道我的电脑使用的任何基本代理,所以这给我留下了两种可能性:
- 或者我搜索我的计算机使用的代理,然后将其填写在
/etc/apt/apt.conf
文件中。 - 或者我进行配置
/etc/apt/apt.conf
以便自动检测代理设置,就像“父” Windows 机器一样。
这两个选项哪一个最好以及我该怎么做?
谢谢
编辑,一些背景
我想做一些sudo apt install
(这是这个超级用户问题,但作为例子,我们以“emacs-gtk”为例):
Linux Prompt> sudo apt install emacs-gtk
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package emacs-gtk
当我这样做时sudo apt update
:
Get:1 http://archive.ubuntu.com/ubuntu focal InRelease
Err:1 http://archive.ubuntu.com/ubuntu focal InRelease
Clearsigned file isn't valid, got 'NOSPLIT' (does the network require authentication?)
Get:2 http://security.ubuntu.com/ubuntu focal-security InRelease
Err:2 http://security.ubuntu.com/ubuntu focal-security InRelease
Clearsigned file isn't valid, got 'NOSPLIT' (does the network require authentication?)
Get:3 http://archive.ubuntu.com/ubuntu focal-updates InRelease
Err:3 http://archive.ubuntu.com/ubuntu focal-updates InRelease
Clearsigned file isn't valid, got 'NOSPLIT' (does the network require authentication?)
Get:4 http://archive.ubuntu.com/ubuntu focal-backports InRelease
Err:4 http://archive.ubuntu.com/ubuntu focal-backports InRelease
Clearsigned file isn't valid, got 'NOSPLIT' (does the network require authentication?)
Reading package lists... Done
N: See apt-secure(8) manpage for repository creation and user configuration details.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
E: The repository 'http://archive.ubuntu.com/ubuntu focal InRelease' is not signed.
E: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/focal/InRelease Clearsigned file isn't valid, got 'NOSPLIT' (does the network require authentication?)
N: See apt-secure(8) manpage for repository creation and user configuration details.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
E: The repository 'http://security.ubuntu.com/ubuntu focal-security InRelease' is not signed.
E: Failed to fetch http://security.ubuntu.com/ubuntu/dists/focal-security/InRelease Clearsigned file isn't valid, got 'NOSPLIT' (does the network require authentication?)
E: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/focal-updates/InRelease Clearsigned file isn't valid, got 'NOSPLIT' (does the network require authentication?)
E: The repository 'http://archive.ubuntu.com/ubuntu focal-updates InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
E: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/focal-backports/InRelease Clearsigned file isn't valid, got 'NOSPLIT' (does the network require authentication?)
E: The repository 'http://archive.ubuntu.com/ubuntu focal-backports InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
根据要求:我 ping 了“8.8.8.8”,一切似乎都正常:
Linux Prompt> ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=116 time=9.47 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=116 time=9.84 ms
...
^C
--- 8.8.8.8 ping statistics ---
6 packets transmitted, 6 received, 0% packet loss, time 5007ms
rtt min/avg/max/mdev = 9.164/9.388/9.838/0.226 ms
我认为apt install
问题是由于/etc/apt/apt.conf
文件(包含代理设置)引起的,因此我提出了这个问题。