码迷,mamicode.com
首页 > 系统相关 > 详细

Ubuntu 12.04更新源

时间:2014-12-10 22:52:35      阅读:232      评论:0      收藏:0      [点我收藏+]

标签:linux   ubuntu   更新源   

    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 restricted
deb-src http://cn.archive.ubuntu.com/ubuntu/ precise main restricted
deb http://cn.archive.ubuntu.com/ubuntu/ precise-updates main restricted
deb-src http://cn.archive.ubuntu.com/ubuntu/ precise-updates main restricted
deb http://cn.archive.ubuntu.com/ubuntu/ precise universe
deb-src http://cn.archive.ubuntu.com/ubuntu/ precise universe
deb http://cn.archive.ubuntu.com/ubuntu/ precise-updates universe
deb-src http://cn.archive.ubuntu.com/ubuntu/ precise-updates universe
deb http://cn.archive.ubuntu.com/ubuntu/ precise multiverse
deb-src http://cn.archive.ubuntu.com/ubuntu/ precise multiverse
deb http://cn.archive.ubuntu.com/ubuntu/ precise-updates multiverse
deb-src http://cn.archive.ubuntu.com/ubuntu/ precise-updates multiverse
deb http://cn.archive.ubuntu.com/ubuntu/ precise-backports main restricted universe multiverse
deb-src http://cn.archive.ubuntu.com/ubuntu/ precise-backports main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu precise-security main restricted
deb-src http://security.ubuntu.com/ubuntu precise-security main restricted
deb http://security.ubuntu.com/ubuntu precise-security universe
deb-src http://security.ubuntu.com/ubuntu precise-security universe
deb http://security.ubuntu.com/ubuntu precise-security multiverse
deb-src http://security.ubuntu.com/ubuntu precise-security multiverse



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

现在试试阿里的源

deb http://mirrors.aliyun.com/ubuntu/ utopic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ utopic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ utopic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ utopic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ utopic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ utopic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ utopic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ utopic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ utopic-proposed main restricted universe multiverse
deb-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操作就可以很快的成功完成了。

Ubuntu 12.04更新源

标签:linux   ubuntu   更新源   

原文地址:http://blog.csdn.net/yu616568/article/details/41854387

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!