虚位以待(AD)
虚位以待(AD)
首页 > 操作系统 > Ubuntu/Debian > Ubuntu12.04更新源

Ubuntu12.04更新源
类别:Ubuntu/Debian   作者:码皇   来源:静下心来,专注于Linux内核,坚持!Come On!!!     点击:

ubuntu的源用来apt-get install会根据源中的url去查找对应的软件(guess),所以源的配置决定着你更新软件的速度,甚至能否找到对应的命令(我就是在安装一个命令发现404的时候才想起来更新的)。当前的系统
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 makeReading package lists... DoneBuilding dependency treeReading state information... DonePackage make is not available, but is referred to by another package.This may mean that the package is missing, has been obsoleted, oris 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操作就可以很快的成功完成了。
相关热词搜索: Ubuntu12 04更新源