如何修改Ubuntu的apt-get源
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了如何修改Ubuntu的apt-get源相关的知识,希望对你有一定的参考价值。
参考技术A1. 备份源列表
[plain] view plain copy
sudo cp /etc/apt/sources.list /etc/apt/sources.list_backup
2. 选择合适的源,替换原文件的内容,保存编辑好的文件
以阿里云更新服务器为例(从实际测试上结果分析,个人认为阿里云比网易和搜狐的服务器要快):
[plain] view plain copy
deb http://mirrors.aliyun.com/ubuntu/ XXXXX main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ XXXXX-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ XXXXX-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ XXXXX-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ XXXXX-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ XXXXX main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ XXXXX-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ XXXXX-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ XXXXX-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ XXXXX-backports main restricted universe multiverse
根据具体使用的Ubuntu的版本不同,将上述文本中XXXXX替换为下面对应版本的字符串:
Utopic(14.10): utopic
Trusty(14.04): trusty
Precise(12.04): precise
Lucid(10.04): lucid
3. 刷新列表
[plain] view plain copy
sudo apt-get update
更新完毕后,再次安装源时,将从新服务器上下载源包。
Ubuntu 修改 apt-get 源为国内镜像源的方法
1、原文件备份
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
2、编辑源列表文件
sudo vim /etc/apt/sources.list
3、将原来的列表删除,添加如下内容(阿里镜像源)
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multivers
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
4、运行 sudo apt-get update
5、如果出现以下错误:
E: 无法获得锁 /var/lib/apt/lists/lock - open (11: 资源暂时不可用)
E: 无法对目录 /var/lib/apt/lists/ 加锁
是因为上一次更新源的时候非常规中断导致的,解决方法如下:
sudo rm /var/lib/apt/lists/lock
以上是关于如何修改Ubuntu的apt-get源的主要内容,如果未能解决你的问题,请参考以下文章