Quickly Configure Mirror Sources for Various Linux Systems in 1 Minute

Quickly Configure Mirror Sources for Various Linux Systems v.1.0

Configuring mirror sources in Linux systems is a key step to enhance the speed of software installation and updates.

This document provides a concise and clear Standard Operating Procedure (SOP) to guide users on how to quickly configure mirror sources in different Linux distributions.

1. Configuring Mirror Sources for Ubuntu/Debian Systems

Step 1: Open the terminal.

Step 2: Use a text editor (such as nano or vim) to open the sources.list file.

sudo vim /etc/apt/sources.list

Step 3: Find the current mirror source address in the file and replace it with the mirror source address closest to your geographical location, which can be found from university or official mirror lists.

Step 4: Save the file and exit the editor.

Step 5: Update the package list to ensure the new mirror source is used.

sudo apt update

Step 6: (Optional) Upgrade all installed packages.

sudo apt upgrade

Configuring Mirror Sources for CentOS/RHEL Systems

Step 1: Open the terminal.

Step 2: Backup the current YUM repository file in case you need to restore it.

sudo cp -a /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

Step 3: Edit the YUM repository file and replace it with the latest mirror source.

sudo vim /etc/yum.repos.d/CentOS-Base.repo

Step 4: Save the file and exit the editor.

Step 5: Clear the cache and generate a new cache.

sudo yum clean all

sudo yum makecache

Configuring Mirror Sources for Fedora Systems

Step 1: Open the terminal.

Step 2: Backup the current DNF repository file.

sudo cp -a /etc/yum.repos.d/fedora.repo /etc/yum.repos.d/fedora.repo.backup

Step 3: Edit the DNF repository file and replace it with the latest mirror source.

sudo vim /etc/yum.repos.d/fedora.repo

Step 4: Save the file and exit the editor.

Step 5: Clear the cache.

sudo dnf clean all

Step 6: Generate a new cache.

sudo dnf makecache

Configuring Mirror Sources for Arch Linux Systems

Step 1: Open the terminal.

Step 2: Edit the mirror list file.

sudo vim /etc/pacman.d/mirrorlist

Step 3: Find and comment out (add # at the beginning of the line) all existing mirror sources in the file.

Step 4: Add one or more recent mirror sources to the top of the file.

Step 5: Save the file and exit the editor.

Step 6: Update the package database.

sudo pacman -Sy

After completing the above steps, your Linux system will use the newly configured mirror sources for software package installation and updates. Please ensure to back up the relevant configuration files before making any changes, so you can restore the original settings if needed.

Red Hat or CentOS Mirror Configuration for Network YUM Source

CentOS 6 System

cd /etc/yum.repos.d/;mkdir all;mv *.repo all/; curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-6.10.repo ; yum makecache

yum -y install epel-release; yum update -y

yum repolist all

CentOS 7 System

cd /etc/yum.repos.d/;mkdir all;mv *.repo all/; wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo

cd /etc/yum.repos.d/;mkdir all;mv *.repo all/; curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo

CentOS 8 (official source has been taken offline, it is recommended to switch to CentOS vault source)

wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo

curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo

How to switch sources when CentOS 8 reaches end of life

Public users:

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

wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo

yum clean all && yum makecache

Aliyun ECS users:

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

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.cloud.aliyuncs.com/repo/Centos-vault-8.5.2111.repo

sed -i ‘s/mirrors.cloud.aliyuncs.com/url_tmp/g’ /etc/yum.repos.d/CentOS-Base.repo && sed -i ‘s/mirrors.aliyun.com/mirrors.cloud.aliyuncs.com/g’ /etc/yum.repos.d/CentOS-Base.repo && sed -i ‘s/url_tmp/mirrors.aliyun.com/g’ /etc/yum.repos.d/CentOS-Base.repo

yum clean all && yum makecache

Other System Series Replacement

sed -i -e ‘/mirrors.cloud.aliyuncs.com/d’ -e ‘/mirrors.aliyuncs.com/d’ /etc/yum.repos.d/CentOS-Base.repo

Ubuntu Mirror Configuration Source /etc/apt/sources.list

Quick Replacement

sed -i ‘s/https://mirrors.aliyun.com/http://mirrors.cloud.aliyuncs.com/g’ /etc/apt/sources.list

Ubuntu 14

deb https://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse

deb-src https://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse

deb https://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse

deb-src https://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse

deb https://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse

deb-src https://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse

deb https://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse

deb-src https://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse

Ubuntu 16

deb https://mirrors.aliyun.com/ubuntu/ xenial main

deb-src https://mirrors.aliyun.com/ubuntu/ xenial main

deb https://mirrors.aliyun.com/ubuntu/ xenial-updates main

deb-src https://mirrors.aliyun.com/ubuntu/ xenial-updates main

deb https://mirrors.aliyun.com/ubuntu/ xenial universe

deb-src https://mirrors.aliyun.com/ubuntu/ xenial universe

deb https://mirrors.aliyun.com/ubuntu/ xenial-updates universe

deb-src https://mirrors.aliyun.com/ubuntu/ xenial-updates universe

deb https://mirrors.aliyun.com/ubuntu/ xenial-security main

deb-src https://mirrors.aliyun.com/ubuntu/ xenial-security main

deb https://mirrors.aliyun.com/ubuntu/ xenial-security universe

deb-src https://mirrors.aliyun.com/ubuntu/ xenial-security universe

Ubuntu 18

deb https://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse

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

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

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

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

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

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

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

Ubuntu 20

deb https://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse

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

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

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

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

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

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

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

Deepin Mirror Configuration Source /etc/apt/sources.list

deepin v20

deb [by-hash=force] https://mirrors.aliyun.com/deepin apricot main contrib non-free

Debian Mirror Configuration Source /etc/apt/sources.list

Quick Replacement

sed -i -E ‘s/(deb|security).debian.org/mirrors.aliyun.com/g’ /etc/apt/sources.list

debian 7

deb https://mirrors.aliyun.com/debian-archive/debian/ wheezy main non-free contrib

deb https://mirrors.aliyun.com/debian-archive/debian/ wheezy-proposed-updates main non-free contrib

deb-src https://mirrors.aliyun.com/debian-archive/debian/ wheezy main non-free contrib

deb-src https://mirrors.aliyun.com/debian-archive/debian/ wheezy-proposed-updates main non-free contrib

debian 8

deb https://mirrors.aliyun.com/debian/ jessie main non-free contrib

deb https://mirrors.aliyun.com/debian/ jessie-proposed-updates main non-free contrib

deb-src https://mirrors.aliyun.com/debian/ jessie

This is a standardized operating procedure to assist users in quickly configuring mirror sources across different Linux systems.

Please follow the corresponding steps based on the Linux distribution you are using.

Leave a Comment