赞
踩
官方镜像文档
cd /etc/apt
- sudo cp sources.list sources.list.bak
- sudo apt-get update
- sudo sed -i 's@//.*archive.ubuntu.com@//mirrors.ustc.edu.cn@g' sources.list
- sudo sed -i 's/security.ubuntu.com/mirrors.ustc.edu.cn/g' sources.list # 可选
- sudo sed -i 's/http:/https:/g' sources.list # 使用HTTPS可以有效避免国内运营商的缓存劫持
sudo vim sources.list
- # 默认注释了源码仓库,如有需要可自行取消注释
- deb https://mirrors.ustc.edu.cn/ubuntu/ focal main restricted universe multiverse
- # deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal main restricted universe multiverse
- deb https://mirrors.ustc.edu.cn/ubuntu/ focal-security main restricted universe multiverse
- # deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal-security main restricted universe multiverse
- deb https://mirrors.ustc.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
- # deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
- deb https://mirrors.ustc.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
- # deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
- # 预发布软件源,不建议启用
- # deb https://mirrors.ustc.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse
- # deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse
若不使用sudo的话用:wq!保存时会出现/etc/apt/sources.list" E212: Can't open file for writing报错,使用如下命令保存并退出shell即可
:w !sudo tee % > /dev/null
sudo apt-get update && sudo apt-get upgrade
常用的Ubuntu版本代号,这里以Ubuntu20.04为例,其它版本直接替换版本代号即可
Ubuntu 24.04:noble
Ubuntu 22.04:jammy
Ubuntu 20.04:focal
Ubuntu 18.04:bionic
- deb https://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
- deb-src https://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
- deb https://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
- deb-src https://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
- deb https://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
- deb-src https://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
- # deb https://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
- # deb-src https://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
- deb https://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
- deb-src https://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
- # 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
- deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
- # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
- deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
- # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
- deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
- # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
- deb http://security.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse
- # deb-src http://security.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse
- # 预发布软件源,不建议启用
- # deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse
- # # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse
- deb http://mirrors.163.com/ubuntu/ focal main restricted universe multiverse
- deb http://mirrors.163.com/ubuntu/ focal-security main restricted universe multiverse
- deb http://mirrors.163.com/ubuntu/ focal-updates main restricted universe multiverse
- deb http://mirrors.163.com/ubuntu/ focal-proposed main restricted universe multiverse
- deb http://mirrors.163.com/ubuntu/ focal-backports main restricted universe multiverse
- deb-src http://mirrors.163.com/ubuntu/ focal main restricted universe multiverse
- deb-src http://mirrors.163.com/ubuntu/ focal-security main restricted universe multiverse
- deb-src http://mirrors.163.com/ubuntu/ focal-updates main restricted universe multiverse
- deb-src http://mirrors.163.com/ubuntu/ focal-proposed main restricted universe multiverse
- deb-src http://mirrors.163.com/ubuntu/ focal-backports main restricted universe multiverse
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。