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 ...
随机推荐
- 完成你的第一个superMap示例
1.从官网下载superMap安装包,我选择setup包 2.解压压缩文件后,按照readme指导书,运行setup.exe进行安装 解压后压缩包包含文件: 执行setup.exe进行安装,其中Sup ...
- 一个在 .NET 一线战斗了十年的 C# 程序员的内心独白
这是我的一个内心独白,内容有点长,希望你能耐心地看完. 估计看到标题,大部分人都会说:哇!大牛!膜拜--之类的.至于是不是大牛,那我不知道,毕竟我依然有很多地方不懂,特别是现在已经流行的 Redis ...
- 深入理解Java内存模型——volatile
volatile的特性 当我们声明共享变量为volatile后,对这个变量的读/写将会非常特别. 理解volatile特性的一个好方法是:把对volatile变量的单个读/写,看成是使用同一个监视器锁 ...
- LintCode-落单的数 III
给出2*n + 2个的数字.除当中两个数字之外其它每一个数字均出现两次,找到这两个数字. 您在真实的面试中是否遇到过这个题? Yes 例子 给出 [1,2,2,3,4,4,5,3].返回 1和5 挑战 ...
- Mac: Android studio+VirtualBox+Genymotion
针对 Mac Yosemite 10.10.4 操作系统 1.在Android Studio 中preferences 中的Plugins 中安装Genymotion插件. Android Studi ...
- CoordinatorLayout与滚动的处理
本博文专门解说和CoordinatorLayout相关的知识点,这也是Design Support Library中最重要与最难的部分. 概览 CoordinatorLayout实现了多种Materi ...
- springboot+jpa+thymeleaf增删改查的示例(转)
这篇文章介绍如何使用jpa和thymeleaf做一个增删改查的示例. 先和大家聊聊我为什么喜欢写这种脚手架的项目,在我学习一门新技术的时候,总是想快速的搭建起一个demo来试试它的效果,越简单越容易上 ...
- Mybatis中的模糊查询
今天下午做的一个功能,要用到模糊查询,字段是description,刚开始我的写法用的是sql中的模糊查询语句, 但是这个有问题,只有将字段的全部值传入其中,才能查询,所以不是迷糊查询. 后来经过搜索 ...
- Caused by: java.net.SocketException: Broken pipe
异常信息 时间:2017-03-24 17:22:16,719 - 级别:[ WARN] - 消息: [other] The web application [ROOT] appears to hav ...
- 《程序设计实践》【PDF】下载
<程序设计实践>[PDF]下载链接: https://u253469.ctfile.com/fs/253469-231196319 内容简介 本书从排错.测试.性能.可移植性.设计.界面. ...