Linux换源

  • 1.Ubuntu换源
  • 1.1 系统换源
  • 1.2 pip换源
  • 1.2.1 临时换源
  • 1.2.1 永久换源
  • Centos换源


本文仅作为个人备忘使用。在折腾seafile过程中由于需要使用docker装linux作为服务器,整合一点换源的命令。

1、清华大学开源软件镜像站
https://mirrors.tuna.tsinghua.edu.cn/ 2、北京交通大学镜像站
https://mirror.bjtu.edu.cn/cn/
3、上海交通大学镜像站
https://mirrors.sjtug.sjtu.edu.cn/
4、浙江大学开源镜像站
https://mirrors.zju.edu.cn/
5、兰州大学开源社区镜像站
https://mirror.lzu.edu.cn/
6、重庆大学开源软件镜像站
https://mirrors.cqu.edu.cn/
7、中国科学技术大学开源软件镜像
http://mirrors.ustc.edu.cn/
8、阿里云开发者社区
https://developer.aliyun.com/mirror/
9、腾讯软件源
https://mirrors.cloud.tencent.com/
10、搜狐镜像站
https://mirrors.sohu.com/
11、网易开源镜像站
https://mirrors.163.com/
12、华为开源镜像站
https://mirrors.huaweicloud.com/home


如何改变文本的样式
强调文本 强调文本
加粗文本 加粗文本
标记文本
删除文本

引用文本
H2O is是液体。
210 运算结果是 1024.

代码块

博客设置页面,选择一款你喜欢的代码片高亮样式,下面展示同样高亮的 代码片.

// An highlighted block var foo = 'bar';

1.Ubuntu换源

1.1 系统换源

1.备份原始源

sudo  cp   /etc/apt/sources.list   /etc/apt/sources.list.bak

2.更换国内源
更改文件权限为可读写

sudo  chmod  777  /etc/apt/sources.list

打开源文件

sudo  vim   /etc/apt/sources.list

备选

sudo  gedit   /etc/apt/sources.list
sudo  vi   /etc/apt/sources.list

##没有安装vim可以执行安装命令
sudo apt-get install vim

键入i启用编辑
更换为以下内容

Ubuntu20.*

deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse

Ubuntu18.*

deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

Ubuntu16.*

deb http://mirrors.aliyun.com/ubuntu/ xenial main
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main
deb http://mirrors.aliyun.com/ubuntu/ xenial universe
deb-src http://mirrors.aliyun.com/ubuntu/ xenial universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main
deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security universe

清华源
(仅列出,本人测试不成功)

# 清华源
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse

键入:
i 插入模式
ESC 退出插入模式
:wq!立即执行保存并退出
:退出编辑模式
q不保存退出
wq保存并退出
!立即执行
————————————————————————————————————
批量注释:
在非插入模式即ESC状态下control+v进入分块(即分行)选择
按上下方向键进行选中,选中完成后键入I(即大写i) 可以输入#/,然后连按两下ESC可实现批量注释

1.2 pip换源

1.2.1 临时换源
pip install ***   -i https://pypi.tuna.tsinghua.edu.cn/simple
1.2.1 永久换源

1.进入用户根目录

cd ~

2.新建隐藏文件夹

mkdir .pip

3.进入该文件夹

cd .pip

4.新建pip源配置文件

touch pip.conf

5.编辑配置文件

vim pip.conf

添加以下内容

#pip.conf
[global]                                                                    
index-url = http://pypi.tuna.tsinghua.edu.cn/simple/
trusted-host = pypi.tuna.tsinghua.edu.cn

Centos换源

以Centos7为例
1.备份原始源

执行命令前先确认是否可以使用wget,若能则跳过本步,若不能则执行:

yum install -y wget

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

2.下载国内源

### Centos7
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
### Centos6
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
### Centos5
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo

以Centos7为例

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

若wget命令不生效,说明还没有安装wget工具,可尝试

curl -O http://mirrors.aliyun.com/repo/Centos-7.repo

3.清空yum缓存并生存cache文件

yum clean all
yum makecache

4.尝试更新系统

yum -y update