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

在此表以感谢!

(转)Ubuntu换源方法的更多相关文章

  1. Ubuntu12.04下安ns-3.29及Ubuntu换源方法

    目录 1.下载ns-3.29 2.安装gcc-4.9.2 3.编译.测试ns-3.29 第一种:更新,文章开头说的 第二种,更新源 主机型号:Ubuntu12.04 仿真环境版本:NS-3.29 安装 ...

  2. ubuntu 换源

    经过自己一番折腾后,发现用这个方法换源最简单.直接. sudo vi /etc/apt/sources.list 把sources.list里面的内容全部替换为一下内容 deb http://mirr ...

  3. python pip换源方法

    以下资料来源于网络: pip国内的一些镜像   阿里云 http://mirrors.aliyun.com/pypi/simple/   中国科技大学 https://pypi.mirrors.ust ...

  4. Ubuntu换源

    转自: http://wiki.ubuntu.org.cn/index.php?title=Qref/Source&variant=zh-cn 不同的网络状况连接以下源的速度不同, 建议在添加 ...

  5. ubuntu 换源过程中遇到的坑(一):Could not resolve 'mirrors.aliyun.com'

    执行更新数据(sudo apt-get update)提示: Err http://mirrors.aliyun.com trusty Release.gpg Could not resolve 'm ...

  6. ubuntu 换源 aliyun

    sudo sed -i 's/archive.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list sudo sed -i 's/securit ...

  7. 装hadoop的第一步,装ubuntu并换源并装jdk

    如何装ubuntu,这个自己百度.具体安装网站:http://www.ubuntu.com 我安装的是ubuntu Server版本的,然后是全英文安装.所以它的源自动定位到美国 下面是如何换源的,第 ...

  8. linux 换源

    Ubuntu换源 ubuntu 的默认源是美国的,所以下载起来特别慢.更换国内源:用vi和gedit 打开 /etc/apt/sources.list 将其中的us.archive 全部替换为 cn. ...

  9. pip & conda 换源

    conda换源方法具体参考清华大学镜像站Anaconda 镜像使用帮助 conda config --add channels https://mirrors.tuna.tsinghua.edu.cn ...

随机推荐

  1. leetcode 207课程表

    class Solution { public: bool canFinish(int numCourses, vector<vector<int>>& prerequ ...

  2. StackTraceElement 源码阅读

    StackTraceElement 属性说明 /** * 每个 StackTraceElement 对象代表一个独立的栈帧,所有栈帧的顶部是一个方法调用 * @since 1.4 * @author ...

  3. 转: zepto的使用方法

    有些不了解zepto的同学在刚接触的时候肯定有很多疑惑,这个东西怎么用啊,去哪里下载啊,什么时候该用什么时候不该用啊,其实我以前也是这样的.jquery使用多了那么就让我们一起来了解下zepto把. ...

  4. SQL server 自增主键重新从1开始

    原文链接:http://blog.csdn.net/zhengjia0826/article/details/43149953 dbcc checkident('sys_common_switch', ...

  5. Void pointers in C

    In this article we are learning about “void pointers” in C language. Before going further it will be ...

  6. pycharm设置背景颜色

    https://jingyan.baidu.com/article/9faa7231f88570473c28cb88.html

  7. [转] An In-Depth Look at the HBase Architecture - HBase架构深度剖析

    [From] https://mapr.com/blog/in-depth-look-hbase-architecture/ In this blog post, I’ll give you an i ...

  8. cpu切换线程上下文会耗费多少时间

    cpu切换线程上下文会耗费多少时间,有人在linux下面使用不同的cpu测试过,需要1000ns以上的时间 https://blog.tsunanet.net/2010/11/how-long-doe ...

  9. postman插件的安装以及简单介绍

    1:postman是干什么的? Postman官网上这么介绍的:“Modern software is built on APIs,Postman helps you develop APIs fas ...

  10. jmeter设置中文语言

    1.在jmeter的bin目录下找到  jmeter.properties  文件并打开 2.搜索关键字 “language”,将37行(以搜索到的位置为准)改成下图所示:language=zh_CN ...