Ubuntu替换国内源(清华源)

第一步

清华大学开源镜像站找到自己的linux系统版本

我的是Ubuntu 18.04LTS:

# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse

# 预发布软件源,不建议启用
# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse

第二步

apt-get配置文件所在的目录为/etc/apt,故先进入目录,然后对原配置文件进行一份备份:sudo cp sources.list sources.list.bak,以防丢失。最后使用vim打开sources.list文件,将原内容删除,替换为新的配置内容(在root模式下进行)。备份命令如下:

ubuntu:~$ cd /etc/apt
ubuntu:/etc/apt$ sudo cp sources.list sources.list.bak

第三步

更新源,使配置生效

ubuntu:~$ sudo apt-get update 
posted @ 2020-03-27 12:07  pengweii  阅读(2662)  评论(0编辑  收藏  举报