Linux下加速软件源访问(中科大)

警告:操作前请先做好备份。
可参考下面的备份方法:
在你想要备份到的目录里打开终端,执行下面的命令。

备份
tar -jpcvf apt.`date +%Y-%m-%d`.tar.bz2 /etc/apt/sources.list /etc/apt/sources.list.d/ /etc/apt/sources.list.save
还原
sudo tar -jxv -f apt.2022-04-05.tar.bz2  -C /

一般软件源

这里推荐中科大的镜像源,点击下面链接,选择当前使用发行版,按教程操作即可。
Ubuntu 源使用帮助
相比清华源,中科大的教程更加人性化。

如果系统是Ubuntu,可以执行以下命令:

sudo sed -i 's/cn.archive.ubuntu.com/mirrors.ustc.edu.cn/g' /etc/apt/sources.list

ppa源

(参考文章ubuntu里的ppa源下载速度太慢了,应该怎么解决?
依旧是USTC,参照其反向代理列表USTC Open Source Software Mirror
每个ppa都会在/etc/apt/sources.list.d/目录下创建一个list文件。
只需把里面的ppa.launchpad.net改为launchpad.proxy.ustclug.orghttp改为https即可。

也可以将以下命令直接复制到终端里执行:

对于某些终端,可能需要在设置里开启正则表达式的支持,比如konsole。
建议手动更改,根据实际情况来修改比较稳妥。

sed -i 's/http://ppa.launchpad.net/launchpad.proxy.ustclug.org/g' /etc/apt/sources.list /etc/apt/sources.list.d/*.list
sed -ri 's#(.*http)(://launchpad.proxy.ustclug.org.*)#\1s\2#g' /etc/apt/sources.list /etc/apt/sources.list.d/*.list
posted @ 2022-04-05 14:48  Leeds_Garden  阅读(1426)  评论(0编辑  收藏  举报