修改apt-get和yum為阿里源
阿新 • • 發佈:2018-12-26
apt-get
在使用apt-get update的時候,出現如下錯誤時:
E: Some index files failed to download, they have been ignored, or old ones used instead.
可以將目錄下/var/lib/apt/lists/partial/所有的檔案清掉,再次執行apt-get update即可!
自帶源在大陸不好,導致無法下載成功
Err http://security.ubuntu.com precise-security Release.gpg
Temporary failure resolving 'security.ubuntu.com'
Err http://cn.archive.ubuntu.com precise InRelease
.......
步驟
首先可以對原檔案進行備份
sudo cp /etc/apt/source.list /etc/apt/source.list.bak
編輯源列表檔案(以管理員身份執行)
sudo vim /etc/apt/source.list
將檔案內容刪除,替換如下內容
deb http://mirrors.aliyun.com/ubuntu/ vivid main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ vivid-security main restricted universe multiverse deb http://mirrors.aliyun
4、執行sudo apt-get update
5、執行sudo apt-get upgrade
yum
1、備份
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
2、下載新的CentOS-Base.repo 到/etc/yum.repos.d/
CentOS 5
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo
CentOS 6
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
CentOS 7
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
3、之後執行yum makecache生成快取