操作流程
查看系统版本
cat /etc/issue
对系统给的镜像源进行备份,以防出问题
sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup
删除镜像源文件
sudo rm /etc/apt/sources.list
重新建立镜像源文件并编辑
sudo nano /etc/apt/sources.list
复制某种镜像源到 sources.list 中,按 ctrl+o 保存,按 ctrl+x退出
镜像源在下方网址中查找
清华镜像源: https://mirrors.tuna.tsinghua.edu.cn/help/ubuntu (Debian 建议使用这个)
中科大镜像源: https://mirrors.ustc.edu.cn/help/ubuntu.html
阿里云: https://developer.aliyun.com/mirror/在 ARM(arm64, armhf)、PowerPC(ppc64el)、RISC-V(riscv64) 和 S390x 等架构的设备上(对应官方源为 ports.ubuntu.com)请使用 ubuntu-ports 镜像。
执行系统更新命令
sudo apt-get update
更新所有软件
sudo apt upgrade
Ubuntu 换源出错
ps: 如果你是在极其特殊的情况下,比如 docker 的 Ubuntu (没有默认文本编辑器),然后又手贱删除了
/etc/apt/sources.list
请使用下列目录来挽救你的系统touch /etc/apt/sources.list echo "deb https://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse" > /etc/apt/sources.list echo "deb-src https://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse" >> /etc/apt/sources.list echo "deb https://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse" >> /etc/apt/sources.list echo "deb-src https://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse" >> /etc/apt/sources.list echo "deb https://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse" >> /etc/apt/sources.list echo "deb-src https://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse" >> /etc/apt/sources.list echo "deb https://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse" >> /etc/apt/sources.list echo "deb-src https://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse" >> /etc/apt/sources.list