Linux 更换国内源
1.事件背景
事情起因是因为我想安装xvfb,执行sudo apt-get install xvfb发现安装报错,看报错原因是被墙导致,因为我用的默认源也没有挂代理;然后就百度,发现都是互相抄,什么换阿里源啊,163源、中科源之类,我都试过,并且发现这些源在更新过程会有一些错误或者更新被忽略,导致我再次执行sudo apt-get install -y xvfb报错说未找到包。
我就接着百度,然后有一条评论给了我灵感,既然默认源切换国区可以安装包,那么我把默认域名us.ports.ubuntu.com换成国内的,us代表美国,zh代表中国,我就试了zh.ports.ubuntu.com,发现真的可以!
2. 替换方法
Ps:我使用的系统是Ubuntu 18.04 LTS
1.先对默认源进行备份
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
2.进入默认源编辑
sudo vi /etc/apt/sources.list
3.全局替换
3.1 按ESC键输入:
3.2 粘贴下面批量替换命令
%s/us\./zh\./g
4. 保存后再执行更新源命令
执行完上述操作步骤后再输入你想安装的包,会发现可以安装了!
最后我想吐槽那些原封不动的抄袭者,虽然转载他人文章可以备份,但是当某一天你想上网查找一个问题的解决方法时,发现全网都是同一个答案,还是一模一样的,而想要找到真正有用的答案无异于海底捞针!
3. 完整源文件备份
默认源文件
# # deb cdrom:[Ubuntu-Server 18.04.3 LTS _Bionic Beaver_ - Release arm64 (20190805)]/ bionic main restricted #deb cdrom:[Ubuntu-Server 18.04.3 LTS _Bionic Beaver_ - Release arm64 (20190805)]/ bionic main restricted # See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://us.ports.ubuntu.com/ubuntu-ports/ bionic main restricted
# deb-src http://us.ports.ubuntu.com/ubuntu-ports/ bionic main restricted ## Major bug fix updates produced after the final release of the
## distribution.
deb http://us.ports.ubuntu.com/ubuntu-ports/ bionic-updates main restricted
# deb-src http://us.ports.ubuntu.com/ubuntu-ports/ bionic-updates main restricted ## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://us.ports.ubuntu.com/ubuntu-ports/ bionic universe
# deb-src http://us.ports.ubuntu.com/ubuntu-ports/ bionic universe
deb http://us.ports.ubuntu.com/ubuntu-ports/ bionic-updates universe
# deb-src http://us.ports.ubuntu.com/ubuntu-ports/ bionic-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://us.ports.ubuntu.com/ubuntu-ports/ bionic multiverse
# deb-src http://us.ports.ubuntu.com/ubuntu-ports/ bionic multiverse
deb http://us.ports.ubuntu.com/ubuntu-ports/ bionic-updates multiverse
# deb-src http://us.ports.ubuntu.com/ubuntu-ports/ bionic-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://us.ports.ubuntu.com/ubuntu-ports/ bionic-backports main restricted universe multiverse
# deb-src http://us.ports.ubuntu.com/ubuntu-ports/ bionic-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 bionic partner
# deb-src http://archive.canonical.com/ubuntu bionic partner deb http://ports.ubuntu.com/ubuntu-ports bionic-security main restricted
# deb-src http://ports.ubuntu.com/ubuntu-ports bionic-security main restricted
deb http://ports.ubuntu.com/ubuntu-ports bionic-security universe
# deb-src http://ports.ubuntu.com/ubuntu-ports bionic-security universe
deb http://ports.ubuntu.com/ubuntu-ports bionic-security multiverse
# deb-src http://ports.ubuntu.com/ubuntu-ports bionic-security multiverse
修改后国内可用源文件
# # deb cdrom:[Ubuntu-Server 18.04.3 LTS _Bionic Beaver_ - Release arm64 (20190805)]/ bionic main restricted #deb cdrom:[Ubuntu-Server 18.04.3 LTS _Bionic Beaver_ - Release arm64 (20190805)]/ bionic main restricted # See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://zh.ports.ubuntu.com/ubuntu-ports/ bionic main restricted
# deb-src http://zh.ports.ubuntu.com/ubuntu-ports/ bionic main restricted ## Major bug fix updates produced after the final release of the
## distribution.
deb http://zh.ports.ubuntu.com/ubuntu-ports/ bionic-updates main restricted
# deb-src http://zh.ports.ubuntu.com/ubuntu-ports/ bionic-updates main restricted ## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://zh.ports.ubuntu.com/ubuntu-ports/ bionic universe
# deb-src http://zh.ports.ubuntu.com/ubuntu-ports/ bionic universe
deb http://zh.ports.ubuntu.com/ubuntu-ports/ bionic-updates universe
# deb-src http://zh.ports.ubuntu.com/ubuntu-ports/ bionic-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://zh.ports.ubuntu.com/ubuntu-ports/ bionic multiverse
# deb-src http://zh.ports.ubuntu.com/ubuntu-ports/ bionic multiverse
deb http://zh.ports.ubuntu.com/ubuntu-ports/ bionic-updates multiverse
# deb-src http://zh.ports.ubuntu.com/ubuntu-ports/ bionic-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://zh.ports.ubuntu.com/ubuntu-ports/ bionic-backports main restricted universe multiverse # deb-src http://zh.ports.ubuntu.com/ubuntu-ports/ bionic-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 bionic partner
# deb-src http://archive.canonical.com/ubuntu bionic partner deb http://ports.ubuntu.com/ubuntu-ports bionic-security main restricted
# deb-src http://ports.ubuntu.com/ubuntu-ports bionic-security main restricted
deb http://ports.ubuntu.com/ubuntu-ports bionic-security universe
# deb-src http://ports.ubuntu.com/ubuntu-ports bionic-security universe
deb http://ports.ubuntu.com/ubuntu-ports bionic-security multiverse
# deb-src http://ports.ubuntu.com/ubuntu-ports bionic-security multiverse
Linux 更换国内源的更多相关文章
- kali linux 更换国内源报GPG error解决办法
wget -q -O - https://archive.kali.org/archive-key.asc | apt-key add
- yum更换国内源、yum下载rpm包、源码包安装 使用介绍
第5周第4次课(4月19日) 课程内容: 7.6 yum更换国内源7.7 yum下载rpm包7.8/7.9 源码包安装 7.6 yum更换国内源 当yum仓库的软件不好用时,例如很多yum源都是国外的 ...
- Ubuntu18.04更换国内源(阿里,网易,中科大,清华等源)
1.备份 备份/etc/apt/sources.list文件 mv /etc/apt/sources.list /etc/apt/sourses.list.backup 2.新建 新建/etc/apt ...
- pip/pip3更换国内源
pip/pip3更换国内源 用途:pip更换为国内源,可以大大的提高安装成功率和速度. Windows更换pip/pip3源 打开目录:%appdata% 新增pip文件夹,新建pip.ini文件 给 ...
- Ubuntu18.04更换国内源
Ubuntu18.04更换国内源 Ubuntu本身的源使用的是国内的源,下载速度比较慢,不像CentOS一样yum安装的时候对镜像站点进项选择, 所以选择了更换成国内的源. 以下内容整合自网络 备份/ ...
- yum更换国内源 yum下载rpm包 源码包安装
7.6 yum更换国内源 7.7 yum下载rpm包 7.8/7.9 源码包安装 yum更换国内源 cd /etc/yum.repo.d/ 删除源 rm -f dvd.repo rm -f C ...
- yum更换国内源及yum下载rpm包
一.yum更换国内源 运维开发技术交流群欢迎大家加入一起学习(QQ:722381733) 1.前往yum文件路径地址 [root@web1 ~]# cd /etc/yum.repos.d/ [root ...
- FreeBSD更换国内源(pkg源使用台湾源,中科大源备用)
安装后第一件事就是更换国内源,不然后面安装桌面等,不用国内源下载太慢. 修改 pkg 源 创建用户级 pkg 源目录:mkdir -p /usr/local/etc/pkg/repos ee /usr ...
- Docker(Docker Toolbox)配置镜像加速更换国内源
自己当时装的是Win10专业工作室版本,不知道为什么不支持window for docker, 所以选择了Docker Toolbox 的方式,主要是为了学习,虽然这种方式是不建议安装的,但是基础的学 ...
随机推荐
- VueX的热更替你知道多少?
前言 我们在使用Vuex的时候,会时不时的更改Vuex内的数据,但是页面不会随之更新,如果数据量大,一个数据依赖另一个数据的话,这样我们要是再刷新页面的话会把以前依赖的数据清空,效率特别低.所以,今天 ...
- 【Java面试】RDB 和 AOF 的实现原理、优缺点
Hi,大家好,我是Mic. 一个工作了5年的粉丝私信我,最近面试碰到很多Redis相关的问题. 其中一个面试官问他Redis里面的持久化机制,没有回答得很好. 希望我帮他系统回答一下. 关于Redis ...
- 实践GoF的23种设计模式:装饰者模式
摘要:装饰者模式通过组合的方式,提供了能够动态地给对象/模块扩展新功能的能力.理论上,只要没有限制,它可以一直把功能叠加下去,具有很高的灵活性. 本文分享自华为云社区<[Go实现]实践GoF的2 ...
- Electron学习(三)之简单交互操作
写在前面 最近一直在做批量测试工具的开发,打包的exe,执行也是一个黑乎乎的dos窗口,真的丑死了,总感觉没个界面,体验不好,所以就想尝试写桌面应用程序. 在技术选型时,Java窗体实现使用JavaF ...
- 常用类-jdk8之前的日期和API
一.System静态方法 点击查看代码 package com.Tang.StringDay01; import org.junit.Test; public class DateTimeTest { ...
- Spring知识点详解
1.Spring 概述 1.1.Spring 的概念和特点 Spring 是一个轻量级的控制反转(IoC)和面向切面(AOP)的开源容器框架,它是由 Rod Johnson(音乐学博士)所创建,其核心 ...
- NOI / 2.5基本算法之搜索-6044:鸣人和佐助详解
总时间限制: 1000ms 内存限制: 65536kB 题目 佐助被大蛇丸诱骗走了,鸣人在多少时间内能追上他呢? 已知一张地图(以二维矩阵的形式表示)以及佐助和鸣人的位置.地图上的每个位置都可以走到, ...
- 算法竞赛进阶指南0x41并查集
并查集简介 并查集的两类操作: Get 查询任意一个元素是属于哪一个集合. Merge 把两个集合合并在一起. 基本思想:找到代表元. 注意有两种方法: 使用一个固定的值(查询方便,但是在合并的时候需 ...
- 20220722-Java可变参数
Java可变参数总结 来源:B站韩顺平老师的Java入门教学 代码示例如下: public void f(String str,int... nums){ 方法体; } 代码示例如下: public ...
- css基础03
就近原则执行粉色.而不是全覆盖,只有样式冲突的地方才会覆盖. 会执行粉色和12px.后来者居上 高度宽度内外边距这些不会继承. 子元素会继承行高, 1.5是行高是字体大小的1.5倍的意思. 有了!im ...