修改 APT 源

手动修改 sources.list

  1. 备份原文件

    1
    sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
  2. 编辑源文件

    1
    sudo nano /etc/apt/sources.list
  3. 替换为官方源(以 Ubuntu 22.04 为例)

    1
    2
    3
    4
    deb http://archive.ubuntu.com/ubuntu jammy main restricted universe multiverse
    deb http://archive.ubuntu.com/ubuntu jammy-updates main restricted universe multiverse
    deb http://archive.ubuntu.com/ubuntu jammy-security main restricted universe multiverse
    deb http://archive.ubuntu.com/ubuntu jammy-backports main restricted universe multiverse

    如需国内镜像,可替换为:

    • 清华源
      1
      2
      3
      4
      deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy main restricted universe multiverse
      deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse
      deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-security main restricted universe multiverse
      deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse
    • 阿里云源
      1
      2
      3
      4
      deb http://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse
      deb http://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse
      deb http://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse
      deb http://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse

替换完成后可以将/etc/apt/sources.list.d内的文件注释,可能会有其他源

  1. 更新软件列表
    1
    2
    sudo apt clean
    sudo apt update