Linux 快速更换软件源
- Linux
- 2019-03-07
- 529热度
- 0评论
镜像下载
[tip type="success" ][/tip]
升级内核
- CentOS 6/7 系列用户
yum clean all && yum makecache #进行软件源更新
yum update kernel -y #更新当前内核版本
reboot #更新后 重启系统生效;
uname -a #检查当前版本是否为最新内核
- Ubuntu 16.04/18.04 LTS 系列用户
apt-get update && apt-get install linux-image-generic #进行软件源更新并安装最新内核版本;
reboot #更新后 重启系统生效;
uname -a #检查当前版本是否为【安全版本】,如果是,则说明修复成功。
# sudo 为可选
安装epel扩展源
- Centos7
yum install -y epel-release
wget -O /etc/yum.repos.d/epel-7.repo http://mirrors.aliyun.com/repo/epel-7.repo
yum clean all
yum makecache
Centos换源命令
查看系统版本
cat /etc/system-release
备份系统源
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
Centos-网易源 (荐)
# Centos7
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.163.com/.help/CentOS7-Base-163.repo
# Centos6
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.163.com/.help/CentOS6-Base-163.repo
# Centos5
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.163.com/.help/CentOS5-Base-163.repo
- 运行以下命令生成缓存
yum clean all
yum makecache
Centos-阿里云源
# 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
- 非阿里云ECS用户会出现 Couldn't resolve host 'mirrors.cloud.aliyuncs.com' 信息,不影响使用。
- 用户也可自行修改相关配置 修改命令如下
sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
- 运行以下命令生成缓存
yum clean all
yum makecache
Debian换源命令
查看系统版本
cat /etc/issue
lsb_release -a
备份系统源
mv /etc/apt/sources.list /etc/apt/sources.list.backup
Debian-网易源 (荐)
# stretch_9
cat > /etc/apt/sources.list<<-EOF
deb http://mirrors.163.com/debian/ stretch main non-free contrib
deb http://mirrors.163.com/debian/ stretch-updates main non-free contrib
deb http://mirrors.163.com/debian/ stretch-backports main non-free contrib
deb-src http://mirrors.163.com/debian/ stretch main non-free contrib
deb-src http://mirrors.163.com/debian/ stretch-updates main non-free contrib
deb-src http://mirrors.163.com/debian/ stretch-backports main non-free contrib
deb http://mirrors.163.com/debian-security/ stretch/updates main non-free contrib
deb-src http://mirrors.163.com/debian-security/ stretch/updates main non-free contrib
EOF
# Jessie_8
cat > /etc/apt/sources.list<<-EOF
deb http://mirrors.163.com/debian/ jessie main non-free contrib
deb http://mirrors.163.com/debian/ jessie-updates main non-free contrib
deb http://mirrors.163.com/debian/ jessie-backports main non-free contrib
deb-src http://mirrors.163.com/debian/ jessie main non-free contrib
deb-src http://mirrors.163.com/debian/ jessie-updates main non-free contrib
deb-src http://mirrors.163.com/debian/ jessie-backports main non-free contrib
deb http://mirrors.163.com/debian-security/ jessie/updates main non-free contrib
deb-src http://mirrors.163.com/debian-security/ jessie/updates main non-free contrib
EOF
# wheezy_7
cat > /etc/apt/sources.list<<-EOF
deb http://mirrors.163.com/debian/ wheezy main non-free contrib
deb http://mirrors.163.com/debian/ wheezy-updates main non-free contrib
deb http://mirrors.163.com/debian/ wheezy-backports main non-free contrib
deb-src http://mirrors.163.com/debian/ wheezy main non-free contrib
deb-src http://mirrors.163.com/debian/ wheezy-updates main non-free contrib
deb-src http://mirrors.163.com/debian/ wheezy-backports main non-free contrib
deb http://mirrors.163.com/debian-security/ wheezy/updates main non-free contrib
deb-src http://mirrors.163.com/debian-security/ wheezy/updates main non-free contrib
EOF
- 运行以下命令生成缓存
apt update && apt upgrade -y
或
apt-get update && apt-get upgrade -y
Debian-阿里云源
# buster_10
cat > /etc/apt/sources.list<<-EOF
deb http://mirrors.aliyun.com/debian/ buster main non-free contrib
deb http://mirrors.aliyun.com/debian/ buster-updates main non-free contrib
deb http://mirrors.aliyun.com/debian/ buster-backports main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ buster main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ buster-updates main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ buster-backports main non-free contrib
deb http://mirrors.aliyun.com/debian-security/ buster/updates main non-free contrib
deb-src http://mirrors.aliyun.com/debian-security/ buster/updates main non-free contrib
EOF
# stretch_9
cat > /etc/apt/sources.list<<-EOF
deb http://mirrors.aliyun.com/debian/ stretch main non-free contrib
deb http://mirrors.aliyun.com/debian/ stretch-updates main non-free contrib
deb http://mirrors.aliyun.com/debian/ stretch-backports main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ stretch main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ stretch-updates main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ stretch-backports main non-free contrib
deb http://mirrors.aliyun.com/debian-security/ stretch/updates main non-free contrib
deb-src http://mirrors.aliyun.com/debian-security/ stretch/updates main non-free contrib
EOF
# Jessie_8
cat > /etc/apt/sources.list<<-EOF
deb http://mirrors.aliyun.com/debian/ jessie main non-free contrib
deb http://mirrors.aliyun.com/debian/ jessie-updates main non-free contrib
deb http://mirrors.aliyun.com/debian/ jessie-backports main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ jessie main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ jessie-updates main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ jessie-backports main non-free contrib
deb http://mirrors.aliyun.com/debian-security/ jessie/updates main non-free contrib
deb-src http://mirrors.aliyun.com/debian-security/ jessie/updates main non-free contrib
EOF
# wheezy_7
cat > /etc/apt/sources.list<<-EOF
deb http://mirrors.aliyun.com/debian/ wheezy main non-free contrib
deb http://mirrors.aliyun.com/debian/ wheezy-updates main non-free contrib
deb http://mirrors.aliyun.com/debian/ wheezy-backports main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ wheezy main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ wheezy-updates main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ wheezy-backports main non-free contrib
deb http://mirrors.aliyun.com/debian-security/ wheezy/updates main non-free contrib
deb-src http://mirrors.aliyun.com/debian-security/ wheezy/updates main non-free contrib
EOF
- 运行以下命令生成缓存
apt update && apt upgrade -y
或
apt-get update && apt-get upgrade -y
Ubuntu换源命令
1查看系统版本
cat /etc/issue
lsb_release -a
备份系统源
# 貌似18下不需要改动这个
# mv /etc/apt/sources.list /etc/apt/sources.list.backup
# Ubuntu_18.04
cat > /etc/apt/sources.list.d/aliyun.list<<-EOF
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
EOF
- 运行以下命令生成缓存
apt update && apt upgrade -y
或
apt-get update && apt-get upgrade -y
其他
# 安装epel源后,更新yum缓存或者安装软件就会出现如下错误。
Cannot retrieve metalink for repository: epel/x86_64. Please verify its path and try again
# 间接方案:将https转为http
sed -i 's#https://#http://#g' /etc/yum.repos.d/epel*repo
wget -N --no-check-certificate https://raw.githubusercontent.com/FunctionClub/LocaleCN/master/LocaleCN.sh && bash LocaleCN.sh