ubuntu更换阿里源
网上应该可以找到很多关于ubuntu源的设置方法,但是如果不搞清楚就随便设置的话,不仅不能起到应有的效果,还会由于一些问题导致apt不可用。
最正确的更换源的方法应该如系统提示的:
## a.) add 'apt_preserve_sources_list: true' to /etc/cloud/cloud.cfg
## or do the same in user-data
## b.) add sources in /etc/apt/sources.list.d
## c.) make changes to template file /etc/cloud/templates/sources.list.tmpl
这种方法有点没弄明白在/etc/apt/sources.list.d应该添加的是什么内容,如果是源文件的话,最后更改的模板又是什么作用?也没有去尝试,有时间会解决一下。
以下提供设置阿里源的方法,其他源也可以如法炮制:
1. 首先查看自己的ubuntu系统的codename,这一步很重要,直接导致你更新的源是否对你的系统起效果,查看方法:
lsb_release -a
如,我的系统显示:
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 14.04.2 LTS
Release: 14.04
Codename: trusty
显示了一些ubuntu的版本信息,需要得到的是Codename,比如,我这里是trusty
2. 确认阿里源支持:
登陆以下网页:http://mirrors.aliyun.com/ubuntu/dists/
该网页显示了阿里云支持的ubuntu系统下各个Codename版本,确保自己的Codename在该网页中存在(一般都会有的)
2. 备份系统源:
cd /etc/apt
sudo mv sources.list sources.list_bak
3. 添加新的源文件:
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
4. 保存并且sudo apt-get update,更新成功
5. 以下提供配置脚本:
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
sudo运行该脚本即可(注意运行之前最好备份之前的sources.list)
ubuntu更换阿里源的更多相关文章
- Ubuntu 更换阿里源
查看新版本信息 lsb_release -c Ubuntu 12.04 (LTS)代号为precise. Ubuntu 14.04 (LTS)代号为trusty. Ubuntu 15.04 代号为vi ...
- ubuntu更换软件源
ubuntu更换软件源 /etc/apt/source.list 163: deb http://mirrors.163.com/ubuntu/ trusty main restricted u ...
- ubuntu16.04LTS更换阿里源
ubuntu16.04LTS更换阿里源 sudo gedit /etc/apt/sources.list 替换: # deb cdrom:[Ubuntu 16.04 LTS _Xenial Xe ...
- Maven更换阿里源与仓库地址
一.为什么要更换maven中的阿里源和仓库地址? 因为咱们下载安装的maven默认配置的源的服务器在国外,所以对于咱们来说,下载jar包的速度会很慢,所以咱们要把它替换为咱们国内的,可以换成好多,如华 ...
- docker ubuntu容器更换阿里源(转)
问题:使用docker 利用下载的ubuntu镜像启动容器时,使用的源下载更新软件的速度较慢. 解决这个问题的方法是跟新ubuntu容器的源 示例:以ubuntu为基础镜像 启动一个名称为 test0 ...
- ubuntu 更换更新源
贴上内容来源https://www.cnblogs.com/Alier/p/6358447.html 1 备份原来的更新源 cp /etc/apt/sources.list /etc/apt/sou ...
- 【Linux】Ubuntu替换阿里源
--------------------------------------------------------- 参考文章:https://www.jianshu.com/p/97c35d569aa ...
- Ubuntu更换科大源
更换科大源 方案一:在命令行输入 sudo gedit /etc/apt/sources.list ,打开系统自带源文件. 将文件内源删除,更换为以下科大源: deb http://mirrors.a ...
- Ubuntu更换镜像源
不同的源 当修改sources.list文件时,我们需要将下面任意一个镜像源的代码复制粘贴到该文件中. 阿里源 # 阿里镜像源 deb http://mirrors.aliyun.com/ubuntu ...
随机推荐
- UWP 共享文件——接收者
UWP上共享,分为接收者(别人共享数据给你,你接收了,然后在做你的处理)和发送者(你给别人发送数据,就像你的App支持图片共享到微信好友或者朋友圈那样,虽然UWP上的微信并不支持这样子) 很简单(参考 ...
- 深入研究-webkit-overflow-scrolling:touch及ios滚动
1. -webkit-overflow-scrolling:touch是什么? MDN上是这样定义的: -webkit-overflow-scrolling 属性控制元素在移动设备上是否使用滚动回弹效 ...
- WPF依赖对象(DependencyObject) 实现源码,理解WPF原理必读
/// DependencyObject encompasses all property engine services. It's primary function /// is providin ...
- 20150605面试汇总--js与java的差别
javascript与java都是编程语言,不同在于代码格式不同. js基于对象,java是面向对象: java是强变量.编译前必须作出声明.js是弱变量,使用前不需做声明: JavaScript 是 ...
- Xcode 7.0 官方免费的真机开发
Xcode 7.0 官方免费的真机开发 太阳火神的漂亮人生 (http://blog.csdn.net/opengl_es) 本文遵循"署名-非商业用途-保持一致"创作公用协议 转 ...
- python 创建列表和向列表添加元素方法
今天的学习内容是python中的列表的相关内容. 一.创建列表 1.创建一个普通列表 >>> tabulation1 = ['大圣','天蓬','卷帘'] >>> ...
- laravel会话驱动扩展—连接自定义会话管理系统
laravel 版本:5.3.* 用laravel开发公司信息系统过程中,由于业务或安全问题的考虑,会有一些特殊的用户会话管理方面的需求,如多个子系统会话统一管理或A系统业务操作导致B系统中某些在线用 ...
- 注册Azure AD 2.0 应用程序
作者:陈希章 发表于 2017年3月22日 上一篇 介绍了Microsoft Graph应用程序的一些概念,以及目前还比较普遍的Azure AD 1.0应用程序的注册方式.但正如我多次提到的那样,虽然 ...
- python+appium+unittest自动化测试框架环境搭建
一.基础软件准备 1.python 版本最新版本,python的IDE使用pycharm.具体的下载链接: python https://www.python.org/ pycharm:https:/ ...
- eclipse点击空白处自动打开项目
如图 选择上面的 Link with Editor 即可