nature book bug burger costumes doctors hospital office shoes skull rocket

Ubuntu apt-get 源设置和更新

由于默认是国外的源,不稳定且慢。另外许多软件包都没有,非常不方便。所以寻思着找修改方式。正巧发现阿里有一个挺好。

通常安装新软件之前,都要先执行两个命令

更新软件包索引

sudo apt-get update

更新软件包

sudo apt-get upgrade

说明一下上面两个命令的用途。
Ubuntu 基于 Debian,默认的包管理工具都是 apt-get,所以上面命令通过 apt-get 操作。
这两个命令通常需要很长时间,并且 upgrade 中间可能出现选择和确认。(所以建议执行的时候先去煮一杯咖啡。)

区别在于第一个用于 获取最新的软件数据 ,而第二个是用于 更新本地软件 。由于这项操作比较耗时,通常也只有安装软件前才做一次。而 apt-get 是 Ubuntu 下默认的包管理器,常见的包管理器还会有 yumbrew

修改源的方法

用喜欢的编辑器编辑源信息管理文件,我用 vi:

sudo vi /etc/apt/sources.list

接着删掉全部内容,用阿里的镜像源替换原本的内容 保存之:

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

deb http://mirrors.aliyuncs.com/ubuntu/ trusty main restricted universe multiverse
deb http://mirrors.aliyuncs.com/ubuntu/ trusty-security main restricted universe multiverse
deb http://mirrors.aliyuncs.com/ubuntu/ trusty-updates main restricted universe multiverse
deb http://mirrors.aliyuncs.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb http://mirrors.aliyuncs.com/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://mirrors.aliyuncs.com/ubuntu/ trusty main restricted universe multiverse
deb-src http://mirrors.aliyuncs.com/ubuntu/ trusty-security main restricted universe multiverse
deb-src http://mirrors.aliyuncs.com/ubuntu/ trusty-updates main restricted universe multiverse
deb-src http://mirrors.aliyuncs.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb-src http://mirrors.aliyuncs.com/ubuntu/ trusty-backports main restricted universe multiverse

替换源以后通常我们会获取一下更新:

sudo apt-get update

参考资料