Ubuntu 12.04更新源

来源:互联网 发布:js从数组中移除元素 编辑:程序博客网 时间:2024/06/15 21:37
    ubuntu的源用来apt-get install会根据源中的url去查找对应的软件(guess),所以源的配置决定着你更新软件的速度,甚至能否找到对应的命令(我就是在安装一个命令发现404的时候才想起来更新的)。

当前的系统的源的信息保存在/etc/apt/sources.list文件中,当前系统的源如下(这个应该是ubuntu 12默认使用的):
terryu@ubuntu:~/workplace/tbnet/trunk/tbsys$ grep -v "^#" /etc/apt/sources.list | grep -v "^$"deb http://cn.archive.ubuntu.com/ubuntu/ precise main restricteddeb-src http://cn.archive.ubuntu.com/ubuntu/ precise main restricteddeb http://cn.archive.ubuntu.com/ubuntu/ precise-updates main restricteddeb-src http://cn.archive.ubuntu.com/ubuntu/ precise-updates main restricteddeb http://cn.archive.ubuntu.com/ubuntu/ precise universedeb-src http://cn.archive.ubuntu.com/ubuntu/ precise universedeb http://cn.archive.ubuntu.com/ubuntu/ precise-updates universedeb-src http://cn.archive.ubuntu.com/ubuntu/ precise-updates universedeb http://cn.archive.ubuntu.com/ubuntu/ precise multiversedeb-src http://cn.archive.ubuntu.com/ubuntu/ precise multiversedeb http://cn.archive.ubuntu.com/ubuntu/ precise-updates multiversedeb-src http://cn.archive.ubuntu.com/ubuntu/ precise-updates multiversedeb http://cn.archive.ubuntu.com/ubuntu/ precise-backports main restricted universe multiversedeb-src http://cn.archive.ubuntu.com/ubuntu/ precise-backports main restricted universe multiversedeb http://security.ubuntu.com/ubuntu precise-security main restricteddeb-src http://security.ubuntu.com/ubuntu precise-security main restricteddeb http://security.ubuntu.com/ubuntu precise-security universedeb-src http://security.ubuntu.com/ubuntu precise-security universedeb http://security.ubuntu.com/ubuntu precise-security multiversedeb-src http://security.ubuntu.com/ubuntu precise-security multiverse



学到grep新的使用方式:^用来匹配一行的开始,-v表示不包含指定字符串的作为满足条件的行,$用来匹配一行的结尾

现在试试阿里的源

deb http://mirrors.aliyun.com/ubuntu/ utopic main restricted universe multiversedeb http://mirrors.aliyun.com/ubuntu/ utopic-security main restricted universe multiversedeb http://mirrors.aliyun.com/ubuntu/ utopic-updates main restricted universe multiversedeb http://mirrors.aliyun.com/ubuntu/ utopic-proposed main restricted universe multiversedeb http://mirrors.aliyun.com/ubuntu/ utopic-backports main restricted universe multiversedeb-src http://mirrors.aliyun.com/ubuntu/ utopic main restricted universe multiversedeb-src http://mirrors.aliyun.com/ubuntu/ utopic-security main restricted universe multiversedeb-src http://mirrors.aliyun.com/ubuntu/ utopic-updates main restricted universe multiversedeb-src http://mirrors.aliyun.com/ubuntu/ utopic-proposed main restricted universe multiversedeb-src http://mirrors.aliyun.com/ubuntu/ utopic-backports main restricted universe multiverse



新命令:sudo sed -i 's/^/#&/g' /etc/apt/sources.list
这个命令可以在指定文件的每一行的开头添加#,当前这里可以替换为任何内容。
将之前的所有源信息注释之后就可以添加新的源了,不过这里折腾得尝试一下如果这个文件里面不存放任何信息,将会出现什么情况呢?

执行sudo apt-get update命令可以更新源,之后再尝试install一个软件。会出现如下的错误:
terryu@ubuntu:~/workplace/tbnet/trunk/tbsys$ sudo apt-get install make
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package make is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'make' has no installation candidate

哈哈,果然这个源对于apt-get很重要,现在尝试使用阿里的源,update的速度还是挺快的。
Get:110 http://mirrors.aliyun.com utopic-backports/restricted Translation-en [14 B]                                                  
Get:111 http://mirrors.aliyun.com utopic-backports/universe Translation-en [6,694 B]                                                 
Fetched 30.1 MB in 1min 16s (394 kB/s)                                                                                               
Reading package lists... Done

update完成之后在执行apt-get install操作就可以很快的成功完成了。

0 0
原创粉丝点击