如何从命令行切换APT镜像?

诺伯特

假设我们使用的是Ubuntu 18.04 LTS(Bionic Beaver)。

我知道切换当前使用的APT镜像的GUI方法。

用户应打开“软件和更新”software-properties-gtksoftware-properties-kde),然后导航到Ubuntu软件Kubuntu Software)选项卡,然后在“以下位置下载”列表中选择镜像

采摘镜

但是如何从命令行切换APT镜像?

注释/更新:

  1. 我需要一个无需直接编辑的解决方案,/etc/apt/sources.list以防止输入错误并自动选择正确的镜像。
  2. 我需要使用一个简单的命令来切换镜像,这等效于从“从以下位置下载”列表中选择一个(相当于software-properties-gtk在系统中保存镜像地址的位置也很有趣)。
    3.我创建了名为“ Ubuntu是否需要用于software-properties-gtk / software-properties-kde的控制台替代方案吗?”的讨论和民意测验。在community.ubuntu.com上
诺伯特

镜像服务器列表由Python库检索(该get_server_list过程在中定义,/usr/lib/python3/dist-packages/aptsources/distro.py并从中调用/usr/lib/python3/dist-packages/softwareproperties/gtk/SoftwarePropertiesGtk.py)。

解决方案是使用名为的工具apt-mirror-updater它可以从pip/安装pip3

sudo pip3 install apt-mirror-updater

功能性:

用法:apt-mirror-updater [选项]

apt-mirror-updater程序通过启用可用镜像的发现,可用镜像的排名,镜像之间的自动切换和健壮的软件包列表更新,自动为Debian和Ubuntu进行健壮的apt-get镜像选择。

支持的选项:

-r,--remote-host = SSH_ALIAS

Operate on a remote system instead of the local system. The SSH_ALIAS
argument gives the SSH alias of the remote host. It is assumed that the
remote account has root privileges or password-less sudo access.

-f,--find-current-mirror

Determine the main mirror that is currently configured in
/etc/apt/sources.list and report its URL on standard output.

-b,-查找最佳镜像

Discover available mirrors, rank them, select the best one and report its
URL on standard output.

-l,--list-mirrors

List available (ranked) mirrors on the terminal in a human readable format.

-c,--change-mirror = MIRROR_URL

Update /etc/apt/sources.list to use the given MIRROR_URL.

-a,--auto-change-mirror

Discover available mirrors, rank the mirrors by connection speed and update
status and update /etc/apt/sources.list to use the best available mirror.

-u,-update,-update-package-lists

Update the package lists using `apt-get update', retrying on failure and
automatically switch to a different mirror when it looks like the current
mirror is being updated.

-x,--exclude =模式

Add a pattern to the mirror selection blacklist. PATTERN is expected to be
a shell pattern (containing wild cards like `?' and `*') that is matched
against the full URL of each mirror.

-m,--max = COUNT

Don't query more than COUNT mirrors for their connection status
(defaults to 50). If you give the number 0 no limit will be applied.

Because Ubuntu mirror discovery can report more than 300 mirrors it's
useful to limit the number of mirrors that are queried, otherwise the
ranking of mirrors will take a long time (because over 300 connections
need to be established).

-v,--verbose

Increase logging verbosity (can be repeated).

-q,-安静

Decrease logging verbosity (can be repeated).

-h,--help

Show this message and exit.

因此,它可以找到最佳的镜像并将其应用于/etc/apt/sources.list

sudo apt-mirror-updater --auto-change-mirror

它还允许通过URL选择镜像并将其应用于/etc/apt/sources.list

$ apt-mirror-updater --list-mirrors
-----------------------------------------------------------------------------------------------------------------------
| Rank | Mirror URL                                        | Available? | Updating? | Last updated   | Bandwidth      |
-----------------------------------------------------------------------------------------------------------------------
|    1 | http://mirror.timeweb.ru/ubuntu                   | Yes        | No        | Up to date     | 6.49 KB/s      |
|    2 | http://no.archive.ubuntu.com/ubuntu               | Yes        | No        | Up to date     | 6.38 KB/s      |
|    3 | http://ftp.aso.ee/ubuntu                          | Yes        | No        | Up to date     | 5.62 KB/s      |
|    4 | http://mirror.plusserver.com/ubuntu/ubuntu        | Yes        | No        | Up to date     | 4.77 KB/s      |
|    5 | http://nl.archive.ubuntu.com/ubuntu               | Yes        | No        | Up to date     | 4.68 KB/s      |
...

然后手动选择镜像:

sudo apt-mirror-updater -c "http://mirror.timeweb.ru/ubuntu"

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

如何从命令行切换APT镜像?

来自分类Dev

从命令行切换等离子主题

来自分类Dev

从命令行切换 Plasma 主题

来自分类Dev

如何从命令行可靠地切换PulseAudio输出设备?

来自分类Dev

如何从命令行手动在耳机和扬声器之间切换

来自分类Dev

如何从命令行手动在耳机和扬声器之间切换

来自分类Dev

从命令行添加新的 APT 镜像

来自分类Dev

从命令行在两种语言输入之间切换

来自分类Dev

有没有办法从命令行切换勿扰模式?

来自分类Dev

如何从命令行中选择最快的镜像?

来自分类Dev

如何从命令行中选择最快的镜像?

来自分类Dev

如何打开从命令行到Firefox的URL,然后“切换到选项卡”?

来自分类Dev

如何打开从命令行到Firefox的URL,然后“切换到选项卡”?

来自分类Dev

如何在Debian 9 / stretch上从命令行切换回GUI

来自分类Dev

如何在命令行上切换cocoapods(或其他gem)版本?

来自分类Dev

如何通过命令行在Windows中切换显示/隐藏隐藏文件?

来自分类Dev

如何通过命令行在Windows 10中切换Wi-Fi?

来自分类Dev

如何从命令行切换选定的脉冲效果均衡器配置文件?

来自分类Dev

如何更改/切换git命令行使用的用户凭据?(Windows 10,Git 2.9.2)

来自分类Dev

如何快速切换UAC开/关,例如。在Windows-7中使用命令行?

来自分类Dev

如何切换到命令行控制台

来自分类Dev

如何切换到命令行控制台

来自分类Dev

如何从命令行打开HUD。

来自分类Dev

如何从命令行打开SourceTree?

来自分类Dev

如何从命令行启动GUI?

来自分类Dev

如何从命令行杀死libreoffice

来自分类Dev

如何从命令行自动挂载?

来自分类Dev

如何从命令行关闭Rserve

来自分类Dev

如何从命令行禁用无线

Related 相关文章

  1. 1

    如何从命令行切换APT镜像?

  2. 2

    从命令行切换等离子主题

  3. 3

    从命令行切换 Plasma 主题

  4. 4

    如何从命令行可靠地切换PulseAudio输出设备?

  5. 5

    如何从命令行手动在耳机和扬声器之间切换

  6. 6

    如何从命令行手动在耳机和扬声器之间切换

  7. 7

    从命令行添加新的 APT 镜像

  8. 8

    从命令行在两种语言输入之间切换

  9. 9

    有没有办法从命令行切换勿扰模式?

  10. 10

    如何从命令行中选择最快的镜像?

  11. 11

    如何从命令行中选择最快的镜像?

  12. 12

    如何打开从命令行到Firefox的URL,然后“切换到选项卡”?

  13. 13

    如何打开从命令行到Firefox的URL,然后“切换到选项卡”?

  14. 14

    如何在Debian 9 / stretch上从命令行切换回GUI

  15. 15

    如何在命令行上切换cocoapods(或其他gem)版本?

  16. 16

    如何通过命令行在Windows中切换显示/隐藏隐藏文件?

  17. 17

    如何通过命令行在Windows 10中切换Wi-Fi?

  18. 18

    如何从命令行切换选定的脉冲效果均衡器配置文件?

  19. 19

    如何更改/切换git命令行使用的用户凭据?(Windows 10,Git 2.9.2)

  20. 20

    如何快速切换UAC开/关,例如。在Windows-7中使用命令行?

  21. 21

    如何切换到命令行控制台

  22. 22

    如何切换到命令行控制台

  23. 23

    如何从命令行打开HUD。

  24. 24

    如何从命令行打开SourceTree?

  25. 25

    如何从命令行启动GUI?

  26. 26

    如何从命令行杀死libreoffice

  27. 27

    如何从命令行自动挂载?

  28. 28

    如何从命令行关闭Rserve

  29. 29

    如何从命令行禁用无线

热门标签

归档