How to view the mirror source of your ubuntu system and change the source

1. View the mirror source currently used by your Ubuntu system:

1. Open the terminal: press Ctrl + Alt + T, or search for "terminal" in the menu.

2. Type the following command and press Enter:

cat /etc/apt/sources.list

The terminal will display a list of all mirror sources in the current system, where the line starting with "deb" specifies the download address of the software package, and the line starting with "deb-src" specifies the download address of the source code.
For example:

# 默认镜像源
deb http://archive.ubuntu.com/ubuntu/ focal main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ focal main restricted universe multiverse

# 阿里云镜像源
deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse

In this example, the first mirror source is the official default source of Ubuntu, and the second mirror source is the Ubuntu mirror source of Alibaba Cloud.
If you want to use other mirror sources, you can add or edit the corresponding lines in this file. When you're done editing, remember to run the following command to update the package list:

sudo apt-get update

2. In the Ubuntu system, you can change the downloaded image source file by modifying the configuration file of the apt-get package manager

1. Open the terminal and enter the following command to back up the original configuration file (optional):

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

2. Edit the source file configuration file:

sudo nano /etc/apt/sources.list

3. Find the corresponding mirror source address in the file, comment out the original address, and add a new address.
For example, to change the default mirror source to the mirror source of Tsinghua University, you can comment out the original address (add # in front), and add the following content:

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

4. Save the file and exit the editor.

5. Update the package list:

sudo apt-get update

The system will now use the new mirror source file for package downloads and updates.

Guess you like

Origin blog.csdn.net/weixin_47869094/article/details/129769689