ToB企服应用市场:ToB评测及商务社交产业平台

标题: Ubuntu更换国内镜像源 [打印本页]

作者: 饭宝    时间: 2024-7-29 01:37
标题: Ubuntu更换国内镜像源
官方镜像文档
  阿里源
  清华源
  中科大源
  网易163源
   1 从根目次进入到sources.list的文件目次中

  1. cd /etc/apt
复制代码
2 备份并更新sources.list

  1. sudo cp sources.list sources.list.bak
  2. sudo apt-get update
复制代码
3 更换国内源

3.1 直接更换

  1. sudo sed -i 's@//.*archive.ubuntu.com@//mirrors.ustc.edu.cn@g' sources.list
  2. sudo sed -i 's/security.ubuntu.com/mirrors.ustc.edu.cn/g' sources.list # 可选
  3. sudo sed -i 's/http:/https:/g' sources.list # 使用HTTPS可以有效避免国内运营商的缓存劫持
复制代码
 3.2 手动更换

3.2.1 打开sources.list

  1. sudo vim sources.list
复制代码
3.2.2 注释或删除官方源,并复制如下中科大源到文件中

  1. # 默认注释了源码仓库,如有需要可自行取消注释
  2. deb https://mirrors.ustc.edu.cn/ubuntu/ focal main restricted universe multiverse
  3. # deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal main restricted universe multiverse
  4. deb https://mirrors.ustc.edu.cn/ubuntu/ focal-security main restricted universe multiverse
  5. # deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal-security main restricted universe multiverse
  6. deb https://mirrors.ustc.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
  7. # deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
  8. deb https://mirrors.ustc.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
  9. # deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
  10. # 预发布软件源,不建议启用
  11. # deb https://mirrors.ustc.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse
  12. # deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse
复制代码
3.2.3 按下Esc后输入:wq!保存

   若不利用sudo的话用:wq!保存时会出现/etc/apt/sources.list" E212: Can't open file for writing报错,利用如下下令保存并退出shell即可
  1. :w !sudo tee % > /dev/null
复制代码
4 执行更新

  1. sudo apt-get update && sudo apt-get upgrade
复制代码

5 其他国内源

   常用的Ubuntu版本代号,这里以Ubuntu20.04为例,别的版本直接更换版本代号即可
  Ubuntu 24.04:noble
  Ubuntu 22.04:jammy
  Ubuntu 20.04:focal
  Ubuntu 18.04:bionic
   5.1 阿里源

  1. deb https://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
  2. deb-src https://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
  3. deb https://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
  4. deb-src https://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
  5. deb https://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
  6. deb-src https://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
  7. # deb https://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
  8. # deb-src https://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
  9. deb https://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
  10. deb-src https://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
复制代码
 5.2 清华源

  1. # 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
  2. deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
  3. # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
  4. deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
  5. # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
  6. deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
  7. # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
  8. deb http://security.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse
  9. # deb-src http://security.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse
  10. # 预发布软件源,不建议启用
  11. # deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse
  12. # # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse
复制代码
 5.3 网易源

  1. deb http://mirrors.163.com/ubuntu/ focal main restricted universe multiverse
  2. deb http://mirrors.163.com/ubuntu/ focal-security main restricted universe multiverse
  3. deb http://mirrors.163.com/ubuntu/ focal-updates main restricted universe multiverse
  4. deb http://mirrors.163.com/ubuntu/ focal-proposed main restricted universe multiverse
  5. deb http://mirrors.163.com/ubuntu/ focal-backports main restricted universe multiverse
  6. deb-src http://mirrors.163.com/ubuntu/ focal main restricted universe multiverse
  7. deb-src http://mirrors.163.com/ubuntu/ focal-security main restricted universe multiverse
  8. deb-src http://mirrors.163.com/ubuntu/ focal-updates main restricted universe multiverse
  9. deb-src http://mirrors.163.com/ubuntu/ focal-proposed main restricted universe multiverse
  10. deb-src http://mirrors.163.com/ubuntu/ focal-backports main restricted universe multiverse
复制代码
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。




欢迎光临 ToB企服应用市场:ToB评测及商务社交产业平台 (https://dis.qidao123.com/) Powered by Discuz! X3.4