本文内容:
1.apt-get的源换成阿里或163的
2.atp-get的源的常识
一、概述
安装好Ubuntu它自带源是国外的,访问较慢,经常会出现连接失败的情况。所以建议将它替换为国内的(如:阿里或163)。
二、替换方法
1、备份原始的Ubuntu源列表
# cp /etc/apt/sources.list /etc/apt/sources.list.backup
2、修改源列表文件
# gedit /etc/apt/sources.list
3、把里面的列表替换成下面的列表
注意:各ubuntu的版本对应的atp-get的源不一样,不能填错,否则用apt-get安装软件报各种奇怪的错。
以下为Ubuntu12.04的atp-get源,如果是其它版本,请将版本名(precise )替换成正确的,对应关系如下:
ubuntu16.04 - xenial
ubuntu15.10 - willy
ubuntu14.04 - trusty
ubuntu12.04 - precise
【阿里云】
deb http://mirrors.aliyun.com/ubuntu/ precise main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ precise-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ precise-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ precise-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ precise-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ precise main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ precise-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ precise-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ precise-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ precise-backports main restricted universe multiverse
【163源 http://mirrors.163.com/ 】
# deb cdrom:[Ubuntu 12.04.2 LTS _Precise Pangolin_ - Release amd64 (20130213)]
deb http://mirrors.163.com/ubuntu/ precise main restricted
deb-src http://mirrors.163.com/ubuntu/ precise main restricted
deb http://mirrors.163.com/ubuntu/ precise-updates main restricted
deb-src http://mirrors.163.com/ubuntu/ precise-updates main restricted
deb http://mirrors.163.com/ubuntu/ precise universe
deb-src http://mirrors.163.com/ubuntu/ precise universe
deb http://mirrors.163.com/ubuntu/ precise-updates universe
deb-src http://mirrors.163.com/ubuntu/ precise-updates universe
deb http://mirrors.163.com/ubuntu/ precise multiverse
deb-src http://mirrors.163.com/ubuntu/ precise multiverse
deb http://mirrors.163.com/ubuntu/ precise-updates multiverse
deb-src http://mirrors.163.com/ubuntu/ precise-updates multiverse
deb http://mirrors.163.com/ubuntu/ precise-backports main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ precise-backports main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ precise-security main restricted
deb-src http://mirrors.163.com/ubuntu/ precise-security main restricted
deb http://mirrors.163.com/ubuntu/ precise-security universe
deb-src http://mirrors.163.com/ubuntu/ precise-security universe
deb http://mirrors.163.com/ubuntu/ precise-security multiverse
deb-src http://mirrors.163.com/ubuntu/ precise-security multiverse
deb http://extras.ubuntu.com/ubuntu precise main
deb-src http://extras.ubuntu.com/ubuntu precise main
4.更新软件源
# apt-get update
三、atp-get源的常识
在 sources.list 文件中,我们看到很多“main,restricted,universe,multiverse”的字眼,这里顺便说一下它们的区别:
以及 precise 的字眼,其实 precise 是 Ubuntu 12.04 的 Code name,更多 Code name 如下所示:
那么,除了 apt-get update,我们平常还会看到 apt-get upgrade 以及 apt-get dist-upgrade,它们的区别是什么呢?查阅相关资料,有如下解释:
An update should always be performed before an upgrade or dist-upgrade. upgrade is used to install the newest versions of all packages currently installed on the system from the sources enumerated in /etc/apt/sources.list. Packages currently installed with new versions available are retrieved and upgraded.
也就是说:
apt-get update:是同步 /etc/apt/sources.list 和 /etc/apt/sources.list.d 中列出的源的索引,这样才能获取到最新的软件包。
apt-get upgrade: 是升级已安装的所有软件包,升级之后的版本就是本地索引里的,因此,在执行 upgrade 之前一定要执行 update, 这样才能是最新的。由于包与包之间存在各种依赖关系,upgrade只是简单的更新包,不管这些依赖,它不和添加包,或是删除包。
apt-get dist-upgrade:可以根据依赖关系的变化,添加包,删除包。
补充:Ubuntu 10.04 LTS (Lucid Lynx)
deb http://old-releases.ubuntu.com/ubuntu lucid main restricted universe multiverse
deb http://old-releases.ubuntu.com/ubuntu lucid-security main restricted universe multiverse
deb http://old-releases.ubuntu.com/ubuntu lucid-updates main restricted universe multiverse
deb http://old-releases.ubuntu.com/ubuntu lucid-proposed main restricted universe multiverse
deb http://old-releases.ubuntu.com/ubuntu lucid-backports main restricted universe multiverse
deb-src http://old-releases.ubuntu.com/ubuntu lucid main restricted universe multiverse
deb-src http://old-releases.ubuntu.com/ubuntu lucid-security main restricted universe multiverse
deb-src http://old-releases.ubuntu.com/ubuntu lucid-updates main restricted universe multiverse
deb-src http://old-releases.ubuntu.com/ubuntu lucid-proposed main restricted universe multiverse
deb-src http://old-releases.ubuntu.com/ubuntu lucid-backports main restricted universe multiverse