我们都知道,Ubuntu的官方源对于国内用户来说是比较慢的,可以将它的源换成国内的源(比如阿里源),这样用起来就很快了。下面记录下更换操作:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
首先了解下
/etc/apt/sources
.list.d文件
文件
/etc/apt/sources
.list是一个普通可编辑的文本文件,保存了ubuntu软件更新的源服务器的地址。
和sources.list功能一样的是
/etc/apt/sources
.list.d/*.list(*代表一个文件名,只能由字母、数字、下划线、英文句号组成),
该文件夹下的文件是第三方软件的源,可以分别存放不同的第三源地址,只需“扩展名”为list即可。
sources.list.d目录下的*.list文件为在单独文件中写入源的地址提供了一种方式,通常用来安装第三方的软件。
如下是ubuntu官方sources.list文件内容:
deb http:
//archive
.ubuntu.com
/ubuntu/
trusty main restricted universe multiverse
deb http:
//archive
.ubuntu.com
/ubuntu/
trusty-security main restricted universe multiverse
deb http:
//archive
.ubuntu.com
/ubuntu/
trusty-updates main restricted universe multiverse
deb http:
//archive
.ubuntu.com
/ubuntu/
trusty-proposed main restricted universe multiverse
deb http:
//archive
.ubuntu.com
/ubuntu/
trusty-backports main restricted universe multiverse
deb-src http:
//archive
.ubuntu.com
/ubuntu/
trusty main restricted universe multiverse
deb-src http:
//archive
.ubuntu.com
/ubuntu/
trusty-security main restricted universe multiverse
deb-src http:
//archive
.ubuntu.com
/ubuntu/
trusty-updates main restricted universe multiverse
deb-src http:
//archive
.ubuntu.com
/ubuntu/
trusty-proposed main restricted universe multiverse
deb-src http:
//archive
.ubuntu.com
/ubuntu/
trusty-backports main restricted universe multiverse
以上内容的具体含义如下:
1)每一行的开头是deb或者deb-src,分别表示直接通过.deb文件进行安装和通过源文件的方式进行安装。
2)deb或者deb-src字段之后,是一段URL,之后是五个用空格隔开的字符串,分别对应相应的目录结构。
在浏览器中输入http:
//archive
.ubuntu.com
/ubuntu/
,并进入dists目录,可以发现有5个目录和前述sources.list文件中的第三列字段相对应。
任选其中一个目录进入,可以看到和sources.list后四列相对应的目录结构
以上官方的ubuntu源在国内使用,通常都会很慢,以至于在使用过程中报错。
----------------下面是我在线上使用过的一个ubuntu的源---------------------
root@ubuntutest03-KVM:~
# cat /etc/apt/sources.list|grep -v "^#"|grep -v "^$"
deb http:
//cn
.archive.ubuntu.com
/ubuntu/
xenial main restricted
deb http:
//cn
.archive.ubuntu.com
/ubuntu/
xenial-updates main restricted
deb http:
//cn
.archive.ubuntu.com
/ubuntu/
xenial universe
deb http:
//cn
.archive.ubuntu.com
/ubuntu/
xenial-updates universe
deb http:
//cn
.archive.ubuntu.com
/ubuntu/
xenial multiverse
deb http:
//cn
.archive.ubuntu.com
/ubuntu/
xenial-updates multiverse
deb http:
//cn
.archive.ubuntu.com
/ubuntu/
xenial-backports main restricted universe multiverse
deb http:
//security
.ubuntu.com
/ubuntu
xenial-security main restricted
deb http:
//security
.ubuntu.com
/ubuntu
xenial-security universe
deb http:
//security
.ubuntu.com
/ubuntu
xenial-security multiverse
--------------下面是替换成阿里源的内容-------------
root@ubuntutest03-KVM:~
# cat /etc/apt/sources.list
deb http:
//mirrors
.aliyun.com
/ubuntu/
xenial main restricted universe multiverse
deb http:
//mirrors
.aliyun.com
/ubuntu/
xenial-security main restricted universe multiverse
deb http:
//mirrors
.aliyun.com
/ubuntu/
xenial-updates main restricted universe multiverse
deb http:
//mirrors
.aliyun.com
/ubuntu/
xenial-backports main restricted universe multiverse
##测试版源
deb http:
//mirrors
.aliyun.com
/ubuntu/
xenial-proposed main restricted universe multiverse
# 源码
deb-src http:
//mirrors
.aliyun.com
/ubuntu/
xenial main restricted universe multiverse
deb-src http:
//mirrors
.aliyun.com
/ubuntu/
xenial-security main restricted universe multiverse
deb-src http:
//mirrors
.aliyun.com
/ubuntu/
xenial-updates main restricted universe multiverse
deb-src http:
//mirrors
.aliyun.com
/ubuntu/
xenial-backports main restricted universe multiverse
##测试版源
deb-src http:
//mirrors
.aliyun.com
/ubuntu/
xenial-proposed main restricted universe multiverse
# Canonical 合作伙伴和附加
deb http:
//archive
.canonical.com
/ubuntu/
xenial partner
deb http:
//extras
.ubuntu.com
/ubuntu/
xenial main
root@ubuntutest03-KVM:~
# apt-get update 更新源
root@ubuntutest03-KVM:~
# apt-get upgrade 更新软件
-------------更换成其他开放的ubuntu源,做法和上面同理----------------
再比如下面更换成网易源(打开文件中的url。进入dists目录下就能看到xenial等对应的目录结构了)
root@ubuntutest03-KVM:~
# cat /etc/apt/sources.list
deb http:
//mirrors
.163.com
/ubuntu/
xenial main restricted
deb http:
//mirrors
.163.com
/ubuntu/
xenial-updates main restricted
deb http:
//mirrors
.163.com
/ubuntu/
xenial universe
deb http:
//mirrors
.163.com
/ubuntu/
xenial-updates universe
deb http:
//mirrors
.163.com
/ubuntu/
xenial multiverse
deb http:
//mirrors
.163.com
/ubuntu/
xenial-updates multiverse
deb http:
//mirrors
.163.com
/ubuntu/
xenial-backports main restricted universe multiverse
deb http:
//security
.ubuntu.com
/ubuntu
xenial-security main restricted
deb http:
//security
.ubuntu.com
/ubuntu
xenial-security universe
deb http:
//security
.ubuntu.com
/ubuntu
xenial-security multiverse
root@ubuntutest03-KVM:~
# apt-get update 更新源
root@ubuntutest03-KVM:~
# apt-get upgrade 更新软件
|
***************当你发现自己的才华撑不起野心时,就请安静下来学习吧***************
本文转自散尽浮华博客园博客,原文链接:http://www.cnblogs.com/kevingrace/p/6699387.html,如需转载请自行联系原作者