I. 查看系统版本及内核

首先查看自己的ubuntu系统的codename,这一步很重要,直接导致你更新的源是否对你的系统起效果,查看方法:

 lsb_release -a
如,我的系统显示:
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 14.04. LTS
Release: 14.04
Codename: trusty 显示了一些ubuntu的版本信息,需要得到的是Codename,比如,我这里是trusty

II. 确认阿里源支持

登陆一下网页:http://mirrors.aliyun.com/ubuntu/dists/

该网页显示了阿里云支持的ubuntu系统下各个Codename版本,确保自己的Codename在该网页中存在(一般都会有的)

III. 备份系统源

 cd /etc/apt
sudo mv sources.list sources.list_bak

IV. 添加新的源文件

 sudo vi sources.list

并添加以下内容:注意,每一行的trusty应该用第一步查看得到的Codename来代替

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

博主天线宝宝6的是xenial,所以用的是:

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-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports 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-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse

这里用了VI

进入vi后,按 i ,然后复制一行源代码,再在Terminal右键Paste,然后按 Esc ,回车,再重复前面的操作,直至复制完最后一行,按了 Esc 后,输入 :wq 后回车存盘并退出vi。

V. 保存与更新

sudo apt-get update

VI. 以下提供配置脚本

Codename=$( (lsb_release -a)|awk '{print $2}'|tail -n  )
echo "\
deb http://mirrors.aliyun.com/ubuntu/ $Codename main multiverse restricted universe
deb http://mirrors.aliyun.com/ubuntu/ $Codename-backports main multiverse restricted universe
deb http://mirrors.aliyun.com/ubuntu/ $Codename-proposed main multiverse restricted universe
deb http://mirrors.aliyun.com/ubuntu/ $Codename-security main multiverse restricted universe
deb http://mirrors.aliyun.com/ubuntu/ $Codename-updates main multiverse restricted universe
deb-src http://mirrors.aliyun.com/ubuntu/ $Codename main multiverse restricted universe
deb-src http://mirrors.aliyun.com/ubuntu/ $Codename-backports main multiverse restricted universe
deb-src http://mirrors.aliyun.com/ubuntu/ $Codename-proposed main multiverse restricted universe
deb-src http://mirrors.aliyun.com/ubuntu/ $Codename-security main multiverse restricted universe
deb-src http://mirrors.aliyun.com/ubuntu/ $Codename-updates main multiverse restricted universe ">sources.list
apt-get update

VII. 国内镜像源内容获得方法

进入官网,在左边的列表中找到Ubuntu,点击Ubuntu右边的问号或者help
帮助文档中信息:

 系统  版本号 名称
Ubuntu 16.04 xenial
Ubuntu 15.10 willy
Ubuntu 14.04 trusty
Ubuntu 12.04 precise
main,restricted,universe,multiverse区别(软件的自由度) 名称 自由度
main 完全的自由软件
restricted 不完全的自由软件
universe ubuntu官方不提供支持与补丁,全靠社区支持
muitiverse 非自由软件,完全不提供支持和补丁
一个源中,以下目录的作用(纯个人猜测) 名称 作用
dists main源存放地
pools security、backports等源的存放地
project 官方源的一个认证

国内速度较快源的网址:

清华TUNA镜像源:https://mirrors.tuna.tsinghua.edu.cn/
中科大USTC镜像源:https://mirrors.ustc.edu.cn/
网易163源:http://mirrors.163.com/ (全称网易开源镜像站,前身cn99源)
搜狐源,其中ubuntu 源是在中国的官方源:http://mirrors.sohu.com/
北京交通大学源:http://mirror.bjtu.edu.cn/cn/

VIII. ubuntu源列表(清华,阿里,官方,选一即可)

Ubuntu的源列表在/etc/apt/sources.list中,替换即可

清华的源

deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial main multiverse restricted universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-backports main multiverse restricted universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-proposed main multiverse restricted universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security main multiverse restricted universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates main multiverse restricted universe
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial main multiverse restricted universe
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-backports main multiverse restricted universe
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-proposed main multiverse restricted universe
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security main multiverse restricted universe
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates main multiverse restricted universe

阿里的源

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-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports 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-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse

官方的源

# deb cdrom:[Ubuntu 16.04 LTS _Xenial Xerus_ - Release amd64 (20160420.1)]/ xenial main restricted
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://cn.archive.ubuntu.com/ubuntu/ xenial main restricted
# deb-src http://cn.archive.ubuntu.com/ubuntu/ xenial main restricted ## Major bug fix updates produced after the final release of the
## distribution.
deb http://cn.archive.ubuntu.com/ubuntu/ xenial-updates main restricted
# deb-src http://cn.archive.ubuntu.com/ubuntu/ xenial-updates main restricted ## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## universe WILL NOT receive any review or updates from the Ubuntu security
## team.
deb http://cn.archive.ubuntu.com/ubuntu/ xenial universe
# deb-src http://cn.archive.ubuntu.com/ubuntu/ xenial universe
deb http://cn.archive.ubuntu.com/ubuntu/ xenial-updates universe
# deb-src http://cn.archive.ubuntu.com/ubuntu/ xenial-updates universe ## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb http://cn.archive.ubuntu.com/ubuntu/ xenial multiverse
# deb-src http://cn.archive.ubuntu.com/ubuntu/ xenial multiverse
deb http://cn.archive.ubuntu.com/ubuntu/ xenial-updates multiverse
# deb-src http://cn.archive.ubuntu.com/ubuntu/ xenial-updates multiverse ## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
deb http://cn.archive.ubuntu.com/ubuntu/ xenial-backports main restricted universe multiverse
# deb-src http://cn.archive.ubuntu.com/ubuntu/ xenial-backports main restricted universe multiverse ## Uncomment the following two lines to add software from Canonical's
## 'partner' repository.
## This software is not part of Ubuntu, but is offered by Canonical and the
## respective vendors as a service to Ubuntu users.
deb http://archive.canonical.com/ubuntu xenial partner
# deb-src http://archive.canonical.com/ubuntu xenial partner deb http://security.ubuntu.com/ubuntu xenial-security main restricted
# deb-src http://security.ubuntu.com/ubuntu xenial-security main restricted
deb http://security.ubuntu.com/ubuntu xenial-security universe
# deb-src http://security.ubuntu.com/ubuntu xenial-security universe
deb http://security.ubuntu.com/ubuntu xenial-security multiverse
# deb-src http://security.ubuntu.com/ubuntu xenial-security multiverse
deb http://cn.archive.ubuntu.com/ubuntu/ xenial-proposed main restricted multiverse universe

文章来源于 https://www.bowu8.com/archives/235/ 及 https://www.cnblogs.com/itech/archive/2009/04/17/1438439.html

在此表以感谢!

最新文章

  1. 如何在vim里删除空行?
  2. .Net如何在后台设置日期格式,并显示在前台页面上
  3. ASP.NET Webform和ASP.NET MVC的区别
  4. RealSense 3D实感体验:前景广阔目前应用少
  5. java se基础
  6. [原创][下载]Senparc.Weixin.MP-微信公众平台SDK(C#) - 已支持微信6.x API
  7. Ural1057 - Amount of Degrees(数位DP)
  8. linuxmit下git安装和初级使用
  9. hdu 5093 Battle ships 匈牙利 很巧妙的建图思路
  10. HDU 3613 Best Reward(扩展KMP)
  11. bzoj2120 数颜色 分块
  12. Navicat如何导出Excel格式表结构
  13. python设计模式---创建型之工厂模式
  14. 【刷题】LOJ 2863 「IOI2018」组合动作
  15. SpringBoot 整合使用dubbo
  16. Windows下开启Redis PHP拓展
  17. jQuery----各版本
  18. ThreadLocal模式与synchronized关键字的比较
  19. 地图经纬度坐标与屏幕坐标的转换(android版)
  20. YQCB冲刺周第六天

热门文章

  1. 什么叫DMZ区?DMZ区有什么作用?应该怎样构建DMZ
  2. numpy之填充为nan的数据为该列平均值
  3. 解决FTP服务器上中文名文件下载后为空的问题
  4. laydate中设置动态改变max与min值的方法
  5. Python 自动化
  6. spring boot系列(一)spring boot 初识
  7. EncryptionAndDecryptionC# 加密 解密
  8. thinkphp6.0 nginx 配置
  9. freetye2使用
  10. 应用安全 - 工具 - Jmeter - 漏洞 - 汇总