更新命令:
$sudo apt-get update #更新
$sudo apt-get upgrade #升级,需要用update更新完才能upgrade
更多详细信息,可运行命令
$man apt-get
记录更新源的文件:/etc/apt/sources.list
默认sources.list中的更新源为官方的,下载速度慢,因此有时需要寻找符合自己需要的更新源。
获取更新源:google“linux更新源”,选择在自己所在的网中比较快的更新源(教育网、网通、电信等等)。
修改默认的更新源:
$sudo cp /etc/apt/sources.list etc/apt/sources.list_backup // 备份更新源
$sudo gedit /etc/apt/sources.list // 打开更新源文件,进行修改
更新源的格式
deb URI distribution component [component2] [component3]
deb-src URI distribution component [component2] [component3]
其中deb是debian包目录,deb-src是源码目录,后者根据需要使用。
例如,在sources.list文件中可能有如下内容:
deb http://security.ubuntu.com/ubuntu maverick-security main restricted
deb-src http://security.ubuntu.com/ubuntu maverick-security main restricted
更新源的格式举例:以更新源http://cn.archive.ubuntu.com/ubuntu/为例
1. 找到一个镜像的URI,如http://cn.archive.ubuntu.com/ubuntu/;
2. 进入dists文件夹,找到自己安装的distribution对应的目录,进入。
这里有dapper, hardy, jaunty, karmic, lucid, maverick, natty等等,下面以maverick为例
进入http://cn.archive.ubuntu.com/ubuntu/dists/maverick/;
3. 记录提供的components名(以/结尾的),这里有main, multiverse, restricted;
4. 则对应的更新源写法为:
dev http://cn.archive.ubuntu.com/ubuntu maverick main multiverse restricted
dev-src http://cn.archive.ubuntu.com/ubuntu maverick main multiverse restricted
注意:每行一个distribution, 多个components。因为每行只能有一个distribution, 所以同一个uri可能写多个更新源。