更换Ubuntu源为国内源的操作记录
我们都知道,Ubuntu的官方源对于国内用户来说是比较慢的,可以将它的源换成国内的源(比如阿里源),这样用起来就很快了。下面记录下更换操作:
首先了解下/etc/apt/sources.list文件
文件/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 更新软件
更换Ubuntu源为国内源的操作记录的更多相关文章
- 转载 - Ubuntu源改国内源 与 批量更改ubuntu机器apt源
change_apt_source.sh # !/bin/bash # 备份原来的源文件 cp /etc/apt/sources.list /etc/apt/sources.list.bak # 获取 ...
- Docker入门之 - 更换源为国内源,实现快速下载image
原文:Docker入门之 - 更换源为国内源,实现快速下载image 版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/u012055638/artic ...
- Linux学习 - 02 使用 - Centos8 - 『更换rpm/epel包源为国内源』
1. Centos8 - 『更换rpm/epel包源为国内源』 centos 8 默认是会读取centos.org的mirrorlist的,所以一般来说是不需要配置镜像的. 如果你的网络访问mirro ...
- pip 源 替换国内源
网上收集来的pip源地址: 阿里云 http://mirrors.aliyun.com/pypi/simple/中国科技大学 https://pypi.mirrors.ustc.edu.cn/simp ...
- Ubuntu armhf 版本国内源
Ubuntu armhf 版本国内源: deb http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial main multiverse restricted u ...
- Ubuntu 18.04修改默认源为国内源
安装Ubuntu 18.04后,使用国外源太慢了,修改为国内源会快很多. 修改阿里源为Ubuntu 18.04默认的源 备份/etc/apt/sources.list 备份 cp /etc/apt/s ...
- Ubuntu 18.04 修改默认源为国内源
1.备份/etc/apt/sources.list #备份 cp /etc/apt/sources.list /etc/apt/sources.list.bak 2.在/etc/apt/sources ...
- Mysql更换MyISAM存储引擎为Innodb的操作记录
一般情况下,mysql会默认提供多种存储引擎,可以通过下面的查看: 1)查看mysql是否安装了innodb插件.通过下面的命令结果可知,已经安装了innodb插件. mysql> show p ...
- debian 9 更换源 使用国内源 配置方法
配置前请先参考: https://wiki.debian.org/SourcesList https://www.debian.org/mirror/list https://mirrors.tuna ...
随机推荐
- entity framework异常 The specified cast from a materialized 'System.Int32' type to the 'System.String' type is not valid
ROW_NUMBER() OVER (ORDER BY (select Null)) AS Id entity framework 查询中有这句会有异常
- lua保留n位小数方法
time:2015/04/21 1. string.format() function GetPreciseDecimal(nNum, n) if type(nNum) ~= "number ...
- Linux : Vim 使用与配置 (附 GitHub 自动化配置脚本)
由于经常使用 vim 编辑配置文件,有时候也会进行使用vim 编写一些脚本和c/c++ 程序,所以配置一个常用的 vim 是很是必要的.这篇博文主要是记录vim使用和配置相关的一些知识点. 关于vim ...
- [MapReduce_add_1] Windows 下开发 MapReduce 程序部署到集群
0. 说明 Windows 下开发 MapReduce 程序部署到集群 1. 前提 在本地开发的时候保证 resource 中包含以下配置文件,从集群的配置文件中拷贝 在 resource 中新建 ...
- Flask入门和快速上手
目录 Flask入门和快速上手 python三大主流框架对比 Flask安装 依赖 可选依赖 创建flask项目 flask最小应用--hello word 非法导入名称 调试模式 路由 唯一的 UR ...
- Nginx安装成Windows服务
因为有项目使用Nginx来做负载均衡,但是Nginx的Windows版本是不提供安装成服务的,所以服务器重启后Nginx并不会伴随启动和恢复.网上查了下,这里记录下解决方法,防止遗忘. 第一步:下载W ...
- WebService Client Generation Error with JDK8
java.lang.AssertionError: org.xml.sax.SAXParseException; systemId: jar:file:/path/to/glassfish/modul ...
- BZOJ1041:[HAOI2008]圆上的整点(数论)
Description 求一个给定的圆(x^2+y^2=r^2),在圆周上有多少个点的坐标是整数. Input 只有一个正整数n,n<=2000 000 000 Output 整点个数 Samp ...
- PHP中使用Elasticsearch
PHP中使用Elasticsearch composer require elasticsearch/elasticsearch 会自动加载合适的版本!我的php是5.6的,它会自动加载5.3的ela ...
- Qt 编程指南 4 按钮2 打开网页和文件夹
功能: 按键打开文件夹和网页 效果: 教程 1 添加两个链接按钮 分别命名 commandLinkButtonFolder 和 commandLinkButtonWeb 2 创建项目 改变调试 ...