Royc30ne

Royc30ne

机器学习 | 联邦学习 | VPS | 摄影 | 日常

[Linux Guide] Record the specific steps to change software sources in Ubuntu.

Finding Available Ubuntu Software Sources#

First, you need to find available Ubuntu software sources. You can find some available Ubuntu software sources on the internet or on some open-source mirror sites in your country. It is recommended to choose Ubuntu software sources that are closer to your geographical location for faster download speeds.

Backing up the Default Ubuntu Software Sources#

Before changing the Ubuntu software sources, it is recommended to back up the original software source list so that you can restore it if needed. The backup method is to copy the default software source list file to another location and rename it, for example:

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

Changing the Ubuntu Software Sources#

Changing the Ubuntu software sources requires editing the /etc/apt/sources.list file. Open the file with a text editor and comment out the original software sources (add the # symbol at the beginning of the line), then add the new software source addresses. For example, we can use Tsinghua University's open-source mirror site as the new Ubuntu software source address:

#deb-src http://archive.ubuntu.com/ubuntu/ focal main restricted
#deb http://archive.ubuntu.com/ubuntu/ focal-updates main restricted
#deb http://archive.ubuntu.com/ubuntu/ focal universe
#deb http://archive.ubuntu.com/ubuntu/ focal-updates universe
#deb http://archive.ubuntu.com/ubuntu/ focal multiverse
#deb http://archive.ubuntu.com/ubuntu/ focal-updates multiverse
#deb http://archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse
#deb http://security.ubuntu.com/ubuntu/ focal-security main restricted
#deb http://security.ubuntu.com/ubuntu/ focal-security universe
#deb http://security.ubuntu.com/ubuntu/ focal-security 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 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

Note that the new software source addresses need to start with deb or deb-src, which represent the addresses of binary files and source code files, respectively.

Updating the Software Source Cache#

After changing the Ubuntu software sources, you need to update the software source cache. You can use the following command to update the cache:

sudo apt update & apt upgrade

How to Verify the Effect of Changing Ubuntu Software Sources?#

After changing the Ubuntu software sources, you can use the following command to verify if the new software sources are effective:

apt-cache policy package-name

Where package-name is the name of the software package. You can enter any installed software package name to verify. If the package can be downloaded from the new software source, it means that the Ubuntu software sources have been successfully changed.

Appendix: Common Sources in China#

#NetEase 163 Source

deb http://mirrors.163.com/ubuntu/ focal main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ focal-security main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ focal-updates main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ focal-backports main restricted universe multiverse
# deb-src http://mirrors.163.com/ubuntu/ focal main restricted universe multiverse
# deb-src http://mirrors.163.com/ubuntu/ focal-security main restricted universe multiverse
# deb-src http://mirrors.163.com/ubuntu/ focal-updates main restricted universe multiverse
# deb-src http://mirrors.163.com/ubuntu/ focal-backports main restricted universe multiverse

#Aliyun Source

deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
#deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
#deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
#deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
#deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
#deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse

#Tsinghua Source

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

#USTC Source

deb https://mirrors.ustc.edu.cn/ubuntu/ focal main restricted universe multiverse
#deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
#deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
#deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ focal-security main restricted universe multiverse
#deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal-security main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse
#deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse

FAQ#

1. Does changing Ubuntu software sources affect system security?#

No, it does not. Changing Ubuntu software sources does not affect the security of the system, it only changes the source of software packages. It is recommended to use certified and verified official software sources or trusted open-source mirror sites.

2. How to find available Ubuntu software source addresses?#

You can search for available Ubuntu software source addresses on the internet or on some open-source mirror sites in your country. It is recommended to choose Ubuntu software sources that are closer to your geographical location for faster download speeds.

3. Does changing Ubuntu software sources cause software package version conflicts?#

It may. Changing Ubuntu software sources may cause software package version conflicts or unsatisfied dependency issues. It is recommended to back up the original software source list before changing Ubuntu software sources and choose appropriate software source addresses based on the actual situation.

4. How to restore to the default Ubuntu software sources?#

You can follow the steps mentioned in this article to restore. It is important to note the backup of the current software source list, updating the software source cache, and other steps.

5. Does changing Ubuntu software sources affect already installed software packages?#

No, it does not. Changing Ubuntu software sources does not affect already installed software packages, it only changes the source for future installations, updates, and uninstallations. Already installed software packages remain unaffected.

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.