In Ubuntu, modifying the software source can speed up software updates and installations, especially for Chinese users, who can replace it with a mainland mirror source (such as Alibaba Cloud, Tsinghua, NetEase, etc.). The following is a detailed modification method:
1. Back up the original software source
Before modifying, it is recommended to back up the original sources.list file to prevent recovery after an error:
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
2. Edit the sources.list file
Use nano or vim to edit Ubuntu's software source list:
sudo nano /etc/apt/sources.list
Or:
sudo vim /etc/apt/sources.list
Clear the original content, and then select the appropriate software source according to your Ubuntu version.
3. Common software sources in mainland China
The following are common mirror sources in mainland China. Choose a suitable one to replace the content in sources.list:
(1) Alibaba Cloud Source
deb http://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ jammy-proposed main restricted universe multiverse
(2) Tsinghua University Source
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-security main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse (3)NetEase source deb http://mirrors.163.com/ubuntu/ jammy main restricted universe multiverse deb http://mirrors.163.com/ubuntu/ jammy-updates main restricted universe multiverse deb http://mirrors.163.com/ubuntu/ jammy-security main restricted universe multiverse deb http://mirrors.163.com/ubuntu/ jammy-backports main restricted universe multiverse
Description:
Ubuntu 22.04 corresponds to codename jammy
Ubuntu 20.04 corresponds to codename focal
Ubuntu 18.04 corresponds to codename bionic
Please replace jammy with the corresponding codename according to your system version.
4. Update software source
After the modification, press Ctrl + X to exit, press Y to save, and then execute:
sudo apt update && sudo apt upgrade -y
5. Restore the original software source (if an error occurs)
If the new source causes problems, you can restore the backup:
sudo cp /etc/apt/sources.list.bak /etc/apt/sources.list
sudo apt update
Through the above method, your Ubuntu can be updated using the faster software source in the mainland!