apt-get 国内源
时间: 2023-08-04 08:13:21 浏览: 147
如果你在使用 Debian 或 Ubuntu 等 Debian 系的 Linux 发行版,你可以通过以下步骤将默认的软件源替换为国内的镜像源。
1. 打开 `/etc/apt/sources.list` 文件,备份原文件:
```
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
```
2. 编辑 `/etc/apt/sources.list` 文件,将所有的 `http://archive.ubuntu.com` 或 `http://deb.debian.org` 替换为以下其中一种镜像源:
- 中科大镜像源(适用于 Debian/Ubuntu 等国内用户常用的 Linux 发行版):
```
deb https://mirrors.ustc.edu.cn/debian/ buster main contrib non-free
deb https://mirrors.ustc.edu.cn/debian/ buster-updates main contrib non-free
deb https://mirrors.ustc.edu.cn/debian/ buster-backports main contrib non-free
deb https://mirrors.ustc.edu.cn/debian-security/ buster/updates main contrib non-free
# Uncomment the following line to add software from the proposed-updates
# repository.
# deb https://mirrors.ustc.edu.cn/debian/ buster-proposed-updates main contrib non-free
```
- 清华大学镜像源(适用于 Debian/Ubuntu 等国内用户常用的 Linux 发行版):
```
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ buster main contrib non-free
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ buster-updates main contrib non-free
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ buster-backports main contrib non-free
deb https://mirrors.tuna.tsinghua.edu.cn/debian-security/ buster/updates main contrib non-free
# Uncomment the following line to add software from the proposed-updates
# repository.
# deb https://mirrors.tuna.tsinghua.edu.cn/debian/ buster-proposed-updates main contrib non-free
```
或
```
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
# Uncomment the following line to add software from Canonical's
# 'partner' repository.
# This software is not part of Ubuntu, but is offered by Canonical and the
# respective vendors as a service to Ubuntu users.
# deb https://partner-mirror.opensyscom.com/ubuntu bionic partner
```
3. 保存文件并退出编辑器。
4. 更新软件源:
```
sudo apt-get update
```
现在,你的 Debian/Ubuntu 等 Debian 系 Linux 发行版系统将会使用国内的镜像源进行软件包的下载和更新。
阅读全文