Linux系统各发行版换国内yum或apt源,加速软件下载更新

简介: Linux系统各发行版换国内yum或apt源,加速软件下载更新

Centos、Ubuntu、Debian、Fedora、OpenSUSE、FreeBSD系统换软件源

Linux系统安装完后软件源一般都是国外服务器,在国内特别慢,这时候就需要更换国内的镜像源。

高性价比和便宜的VPS/云服务器推荐:https://blog.zeruns.tech/archives/383.html

Centos

1、备份

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

2、更换源

下载新的CentOS-Base.repo/etc/yum.repos.d/

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

或者

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

注意http://mirrors.aliyun.com/repo/Centos-7.repo中的7改为自己的Centos版本号,比如Centos 8就是http://mirrors.aliyun.com/repo/Centos-8.repo

3、运行yum makecache生成缓存

yum makecache

Ubuntu

1.备份

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

将以前的源备份一下,以防以后可以用的。

2.更改文件权限使其可编辑

sudo  chmod  777  /etc/apt/source.list

3.更换源

sudo nano /etc/apt/sources.list

使用nano打开文本,删除原来文件里的内容,将下面其中一个源复制进去,然后保存。

阿里源:

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-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports 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-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse

清华源:

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

3.更新

更新源

sudo apt-get update

修复损坏的软件包,尝试卸载出错的包,重新安装正确版本的。

sudo apt-get -f install

更新软件

sudo apt-get upgrade

Debian

1.备份

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

2.更换源

一般情况下,将/etc/apt/sources.list文件中 Debian 默认的源地址http://deb.debian.org替换为http://mirrors.ustc.edu.cn(清华源)即可。

sudo sed -i 's/deb.debian.org/mirrors.ustc.edu.cn/g' /etc/apt/sources.list

也可以直接编辑/etc/apt/sources.list文件(v)

sudo vi /etc/apt/sources.list

加入如下内容即可

deb http://mirrors.ustc.edu.cn/debian stable main contrib non-free
# deb-src http://mirrors.ustc.edu.cn/debian stable main contrib non-free
deb http://mirrors.ustc.edu.cn/debian stable-updates main contrib non-free
# deb-src http://mirrors.ustc.edu.cn/debian stable-updates main contrib non-free

# deb http://mirrors.ustc.edu.cn/debian stable-proposed-updates main contrib non-free
# deb-src http://mirrors.ustc.edu.cn/debian stable-proposed-updates main contrib non-free

敲击i键进入插入模式,组合键ctrl+shift+v将复制内容粘贴至源文件中,敲击esc键进入命令模式,输入:wq!保存并退出。

其他镜像源:
阿里云:http://mirrors.aliyun.com/
搜狐:http://mirrors.sohu.com/
网易:http://mirrors.163.com/

3.更新

sudo apt-get update

Fedora

su
cd /etc/yum.repos.d/
mv fedora.repo fedora.repo.backup
mv fedora-updates.repo fedora-updates.repo.backup
wget -O /etc/yum.repos.d/fedora.repo http://mirrors.aliyun.com/repo/fedora.repo
wget -O /etc/yum.repos.d/fedora-updates.repo http://mirrors.aliyun.com/repo/fedora-updates.repo
dnf clean all
dnf makecache

OpenSUSE

1.禁用原有软件源

sudo zypper mr -da

2.添加科大镜像源

sudo zypper ar -fc https://mirrors.ustc.edu.cn/opensuse/distribution/leap/42.1/repo/oss USTC:42.1:OSS
sudo zypper ar -fc https://mirrors.ustc.edu.cn/opensuse/distribution/leap/42.1/repo/non-oss USTC:42.1:NON-OSS
sudo zypper ar -fc https://mirrors.ustc.edu.cn/opensuse/update/leap/42.1/oss USTC:42.1:UPDATE-OSS
sudo zypper ar -fc https://mirrors.ustc.edu.cn/opensuse/update/leap/42.1/non-oss USTC:42.1:UPDATE-NON-OSS

3.手动刷新软件源

sudo zypper ref

4.更新系统

sudo zypper up

FreeBSD

1.修改 pkg 源

mkdir -p /usr/local/etc/pkg/repos
vim /usr/local/etc/pkg/repos/FreeBSD.conf

# content of FreeBSD.conf
FreeBSD: {
    url: "pkg+http://mirrors.ustc.edu.cn/freebsd-pkg/${ABI}/quarterly",
}

2.修改 ports 源

vim /etc/make.conf

# content of make.conf
FETCH_CMD=axel -n 10 -a
DISABLE_SIZE=yes
MASTER_SITE_OVERRIDE?=http://mirrors.ustc.edu.cn/freebsd-ports/distfiles/${DIST_SUBDIR}/

3.修改 portsnap 源

vim /etc/portsnap.conf

# content of porsnap.conf
SERVERNAME=porsnap.tw.freebsd.org

推荐文章:

搭建内网穿透服务器,带Web面板:https://blog.zeruns.tech/archives/397.html

怎样搭建个人博客:https://blog.zeruns.tech/archives/218.html

CentOS 7安装新内核并启用Google BBR教程:https://blog.zeruns.tech/archives/39.html

vultr $2.5 纯ipv6服务器+CDN搭建同时支持ipv4和ipv6的网站:https://blog.zeruns.tech/archives/345.html

搭建AdGuard Home无广告及跟踪的DNS解析服务器:https://blog.zeruns.tech/archives/318.html

目录
相关文章
|
JavaScript Linux 网络安全
Termux安卓终端美化与开发实战:从下载到插件优化,小白也能玩转Linux
Termux是一款安卓平台上的开源终端模拟器,支持apt包管理、SSH连接及Python/Node.js/C++开发环境搭建,被誉为“手机上的Linux系统”。其特点包括零ROOT权限、跨平台开发和强大扩展性。本文详细介绍其安装准备、基础与高级环境配置、必备插件推荐、常见问题解决方法以及延伸学习资源,帮助用户充分利用Termux进行开发与学习。适用于Android 7+设备,原创内容转载请注明来源。
4511 77
|
9月前
|
Ubuntu Linux
Ubuntu Linux 20.04 LTS “Focal Fossa”测试版开放下载
u要知道有关新系统的更多信息,大家可以前往Ubuntu Wiki页面,其中包含Ubuntu 20.04的发行说明。
247 0
|
9月前
|
Ubuntu 安全 Linux
Linux系统-Ubuntu的下载和安装 软件大全
在庄子看来,生老病死就像四时交替,都只是自然现象而已,人不必有什么忧虑,也不必有什么痛苦。人源于自然,再回归自然,说到底,不过是正常的生死轮转,他依然在天地之间,只要怀着这样的想法,人又有什么好痛苦的呢。
|
9月前
|
Ubuntu Linux Windows
Ubuntu Linux 24.04 LTS 发行版现已开放下载
Ubuntu 24.04 采用了 Linux 6.8 内核,可利用 Netplan 在桌面上配置网络连接,还配备了现代化的桌面操作系统安装程序,还带来了新版 Ubuntu 字体以及各种性能优化以及大量新功能。
|
11月前
|
NoSQL Linux 开发工具
Linux环境基础开发工具的使用(yum、vim、gcc、g++、gdb、make/Makefile)
本文介绍了yum 包管理工具、Vim 编辑器、gcc/g++ 编译器、gdb 调试器、编译原理及 Makefile 的使用,同时还配备了如何使用,以及图解。旨在帮助读者更好地理解和应用这些工具与技术。
562 0
|
Ubuntu Linux 网络安全
Linux 之Python 定制篇-APT 软件管理和远程登录
Linux 之Python 定制篇-APT 软件管理和远程登录
400 1
|
Ubuntu 安全 Unix
【Linux】apt软件管理和远程登录
【Linux】apt软件管理和远程登录
575 0
【Linux】apt软件管理和远程登录
|
8月前
|
Linux 应用服务中间件 Shell
二、Linux文本处理与文件操作核心命令
熟悉了Linux的基本“行走”后,就该拿起真正的“工具”干活了。用grep这个“放大镜”在文件里搜索内容,用find这个“探测器”在系统中寻找文件,再用tar把东西打包带走。最关键的是要学会使用管道符|,它像一条流水线,能把这些命令串联起来,让简单工具组合出强大的功能,比如 ps -ef | grep 'nginx' 就能快速找出nginx进程。
952 1
二、Linux文本处理与文件操作核心命令
|
8月前
|
Linux
linux命令—stat
`stat` 是 Linux 系统中用于查看文件或文件系统详细状态信息的命令。相比 `ls -l`,它提供更全面的信息,包括文件大小、权限、所有者、时间戳(最后访问、修改、状态变更时间)、inode 号、设备信息等。其常用选项包括 `-f` 查看文件系统状态、`-t` 以简洁格式输出、`-L` 跟踪符号链接,以及 `-c` 或 `--format` 自定义输出格式。通过这些选项,用户可以灵活获取所需信息,适用于系统调试、权限检查、磁盘管理等场景。
546 137