如何更换安装Linux源?
Linux
如何更换安装Linux源?
2023-01-13 17:29
|
执行以下脚本,自动根据您的系统进行全自动化操作换YUM
- wget http://mirrors.qingyunl.com/Shell/vps/yum_apt_select.sh;bash yum_apt_select.sh
国内优秀安装源---清华源
1、CentOS7
①、先备份当前的安装源目录
- \cp -rp /etc/yum.repos.d/ /etc/yum.repos.d_back
②、注释mirrorlist
- sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*.repo
③、将baseurl的地址指向清华源
- sed -i 's|#baseurl=http://mirror.centos.org|baseurl=https://mirrors.tuna.tsinghua.edu.cn|g' /etc/yum.repos.d/CentOS-*.repo
替换后,执行下面命令进行生成软件包的缓存
- yum clean all
- yum makecache
##############Ubuntu系列#################
仅仅提供LTS系列和Ubuntu21的安装源
2、Ubuntu18.04LTS
①、备份当前的安装源
- \cp -rp /etc/apt/sources.list /etc/apt/sources.list_back
- echo "" >/etc/apt/sources.list
②、添加清华源
- cat >/etc/apt/sources.list <<EOF
- # 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
- 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
- EOF
③、更新软件包缓存
- apt-get update -y
④、如果无法拉取https源的情况,请执行下面命令再重新执行③
- apt install apt-transport-https ca-certificates
2.1、Ubuntu20.04 LTS
①、备份当前的安装源
- \cp -rp /etc/apt/sources.list /etc/apt/sources.list_back
- echo "" >/etc/apt/sources.list
②、添加清华源
- cat > /etc/apt/sources.list<<EOF
- # 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
- deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
- # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
- deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
- # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
- deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
- # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
- deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse
- # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse
- # 预发布软件源,不建议启用
- # deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse
- # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse
- EOF
③、更新软件包缓存
- apt-get update -y
④、如果无法拉取https源的情况,请执行下面命令再重新执行③
- apt install apt-transport-https ca-certificates
2.3、Ubuntu21.04
①、备份当前的安装源
- \cp -rp /etc/apt/sources.list /etc/apt/sources.list_back
- echo "" >/etc/apt/sources.list
②、添加清华源
- cat >/etc/apt/sources.list <<EOF
- # 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
- deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ hirsute main restricted universe multiverse
- # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ hirsute main restricted universe multiverse
- deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ hirsute-updates main restricted universe multiverse
- # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ hirsute-updates main restricted universe multiverse
- deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ hirsute-backports main restricted universe multiverse
- # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ hirsute-backports main restricted universe multiverse
- deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ hirsute-security main restricted universe multiverse
- # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ hirsute-security main restricted universe multiverse
- # 预发布软件源,不建议启用
- # deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ hirsute-proposed main restricted universe multiverse
- # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ hirsute-proposed main restricted universe multiverse
- EOF
③、更新软件包缓存
- apt-get update -y
④、如果无法拉取https源的情况,请执行下面命令再重新执行③
- apt install apt-transport-https ca-certificates
############Debian系列##############
debian系列暂时只考虑 bullseye发行版(其他的版本请参考清华源:https://mirrors.tuna.tsinghua.edu.cn/help/debian/)
①、备份当前的安装源
- \cp -rp /etc/apt/sources.list /etc/apt/sources.list_back
- echo "" >/etc/apt/sources.list
②、添加清华源
- cat >/etc/apt/sources.list <<EOF
- # 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
- deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye main contrib non-free
- # deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye main contrib non-free
- deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-updates main contrib non-free
- # deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-updates main contrib non-free
- deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-backports main contrib non-free
- # deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-backports main contrib non-free
- deb https://mirrors.tuna.tsinghua.edu.cn/debian-security bullseye-security main contrib non-free
- # deb-src https://mirrors.tuna.tsinghua.edu.cn/debian-security bullseye-security main contrib non-free
- EOF
③、更新软件包缓存
- apt-get update -y
④、如果无法拉取https源的情况,请执行下面命令再重新执行③
- apt install apt-transport-https ca-certificates