1 首先对源列表做好备份:
sudo cp /etc/apt/sources.list /etc/apt/sources.list_backup
2 根据系统不同选择合适的编辑编辑器打开原列表:
sudo vii /etc/apt/sources.list
3.用找到的更新源替换原先的。
4.收尾工作:
sudo apt-get update
如果发现无法正常更新,请使用备份还原:
sudo cp /etc/apt/sources.list_backup /etc/apt/sources.list
备注:
我在替换更新源的时候遇到以下情况
Err http://cn.archive.ubuntu.com precise InRelease Err http://security.ubuntu.com precise-security InRelease Err http://cn.archive.ubuntu.com precise-updates InRelease Err http://cn.archive.ubuntu.com precise Release.gpg Temporary failure resolving 'cn.archive.ubuntu.com' Err http://security.ubuntu.com precise-security Release.gpg Temporary failure resolving 'security.ubuntu.com' Err http://cn.archive.ubuntu.com precise-updates Release.gpg Temporary failure resolving 'cn.archive.ubuntu.com' Reading package lists... Done W: Failed to fetch http://cn.archive.ubuntu.com/ubuntu/dists/precise/InRelease W: Failed to fetch http://cn.archive.ubuntu.com/ubuntu/dists/precise-updates/InRelease W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/precise-security/InRelease W: Failed to fetch http://cn.archive.ubuntu.com/ubuntu/dists/precise/Release.gpg Temporary failure resolving 'cn.archive.ubuntu.com' W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/precise-security/Release.gpg Temporary failure resolving 'security.ubuntu.com' W: Failed to fetch http://cn.archive.ubuntu.com/ubuntu/dists/precise-updates/Release.gpg Temporary failure resolving 'cn.archive.ubuntu.com' W: Some index files failed to download. They have been ignored, or old ones used instead.
解决方法:
1.查看增加的源是否正确
2.查看网络是否正常(我这由于dns没有指定,导致了以上的错误)