Ubuntu 24.04 给APT换国内源
Ubuntu 24.04下,APT源的格式相较之前有变动,之前的经验是不可用的。
路径: /etc/apt/sources.list.d/ubuntu.sources
打开这个路径:
cd /etc/apt/sources.list.d
sudo cp ubuntu.sources ubuntu.sources_cp
sudo rm -rf ubuntu.sources
sudo vim ubuntu.sources
按i键,粘贴以下代码:
Types: deb URIs: https://mirrors.ustc.edu.cn/ubuntu/ Suites: noble noble-updates noble-security Components: main restricted universe multiverse Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg Types: deb URIs: https://mirrors.aliyun.com/ubuntu/ Suites: noble noble-updates noble-security Components: main restricted universe multiverse Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg Types: deb URIs: https://repo.huaweicloud.com/ubuntu/ Suites: noble noble-updates noble-security Components: main restricted universe multiverse Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg Types: deb URIS: https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ Suites: noble noble-updates noble-security Components: main restricted universe multiverse Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
包含了4个国内源。如需改动,只需改URIS那行,其他完全不需要动。
保存并退出vim。
:wq!
执行命令使得国内源生效:
sudo apt update
sudo apt upgrade
完成。