Ubuntu 24.04 apt 更换国内镜像站源

打印 上一主题 下一主题

主题 784|帖子 784|积分 2352

Ubuntu 24.04 LTS 后的source.list

24.04LTS 后,apt源的位置更换到了/etc/apt/sources.list.d/ubuntu.sources中
  1. /etc/apt/sources.list
  2. # Ubuntu sources have moved to the /etc/apt/sources.list.d/ubuntu.sources
  3. # file, which uses the deb822 format. Use deb822-formatted .sources files
  4. # to manage package sources in the /etc/apt/sources.list.d/ directory.
  5. # See the sources.list(5) manual page for details.
复制代码
同时,格式改变,现在为DEB822格式,详见这里
现在的格式是这样的
  1. /etc/apt/sources.list.d/ubuntu.sources
  2. ##      /etc/cloud/templates/sources.list.ubuntu.deb822.tmpl
  3. ##
  4. # See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
  5. # newer versions of the distribution.
  6. ## Ubuntu distribution repository
  7. ##
  8. ## The following settings can be adjusted to configure which packages to use from Ubuntu.
  9. ## Mirror your choices (except for URIs and Suites) in the security section below to
  10. ## ensure timely security updates.
  11. ##
  12. ## Types: Append deb-src to enable the fetching of source package.
  13. ## URIs: A URL to the repository (you may add multiple URLs)
  14. ## Suites: The following additional suites can be configured
  15. ##   <name>-updates   - Major bug fix updates produced after the final release of the
  16. ##                      distribution.
  17. ##   <name>-backports - software from this repository may not have been tested as
  18. ##                      extensively as that contained in the main release, although it includes
  19. ##                      newer versions of some applications which may provide useful features.
  20. ##                      Also, please note that software in backports WILL NOT receive any review
  21. ##                      or updates from the Ubuntu security team.
  22. ## Components: Aside from main, the following components can be added to the list
  23. ##   restricted  - Software that may not be under a free license, or protected by patents.
  24. ##   universe    - Community maintained packages.
  25. ##                 Software from this repository is only maintained and supported by Canonical
  26. ##                 for machines with Ubuntu Pro subscriptions. Without Ubuntu Pro, the Ubuntu
  27. ##                 community provides best-effort security maintenance.
  28. ##   multiverse  - Community maintained of restricted. Software from this repository is
  29. ##                 ENTIRELY UNSUPPORTED by the Ubuntu team, and may not be under a free
  30. ##                 licence. Please satisfy yourself as to your rights to use the software.
  31. ##                 Also, please note that software in multiverse WILL NOT receive any
  32. ##                 review or updates from the Ubuntu security team.
  33. ##
  34. ## See the sources.list(5) manual page for further settings.
  35. Types: deb
  36. URIs: http://archive.ubuntu.com/ubuntu
  37. Suites: noble noble-updates noble-backports
  38. Components: main universe restricted multiverse
  39. Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
  40. ## Ubuntu security updates. Aside from URIs and Suites,
  41. ## this should mirror your choices in the previous section.
  42. Types: deb
  43. URIs: http://security.ubuntu.com/ubuntu
  44. Suites: noble-security
  45. Components: main universe restricted multiverse
  46. Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
复制代码
因此,假如要使用国内诸如清华TUNA源,USTC源,也需要使用新格式
详细方法

sources.list.d文件夹中,所有.sources拓展名结尾的文件均会被作为一个可选的源
因此我们将原始文件备份:
  1. sudo mv /etc/apt/sources.list.d/ubuntu.sources  /etc/apt/backup-sources.list.d-ubuntu.sources
复制代码
然后创建一个新的文件,以.sources结尾,例如
  1. sudo vim /etc/apt/sources.list.d/tuna.sources
复制代码
内里填入
  1. Types: deb
  2. URIs: https://mirrors.tuna.tsinghua.edu.cn/ubuntu/
  3. #如果使用其他镜像站,上面这行可以改成其他镜像站的网址
  4. Suites: noble noble-updates noble-backports
  5. Components: main universe restricted multiverse
  6. Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
  7. Types: deb
  8. URIs: http://security.ubuntu.com/ubuntu
  9. #如果安全更新需要使用镜像站,上面这行也改成 URIs: https://mirrors.tuna.tsinghua.edu.cn/ubuntu/
  10. Suites: noble-security
  11. Components: main universe restricted multiverse
  12. Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
复制代码
之后运行
  1. $ sudo apt update
  2. $ sudo apt upgrade
复制代码
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
回复

使用道具 举报

0 个回复

正序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

农妇山泉一亩田

金牌会员
这个人很懒什么都没写!

标签云

快速回复 返回顶部 返回列表