简介Ubuntu作为一款广泛使用的Linux发行版,其软件安装与更新依赖于软件源。由于网络原因,从国外源下载软件可能会比较慢。本文将介绍如何将Ubuntu软件源切换到国内镜像,以加速软件的安装与更新。...
Ubuntu作为一款广泛使用的Linux发行版,其软件安装与更新依赖于软件源。由于网络原因,从国外源下载软件可能会比较慢。本文将介绍如何将Ubuntu软件源切换到国内镜像,以加速软件的安装与更新。
在开始之前,请确保您的Ubuntu系统已更新到最新状态,以便从新源列表中获取最新软件包。
/etc/apt/sources.list文件:sudo nano /etc/apt/sources.listdeb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ $(lsb_release -cs) main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ $(lsb_release -cs)-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ $(lsb_release -cs)-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ $(lsb_release -cs)-security main restricted universe multiversesudo apt update如果您不想手动编辑文件,可以使用以下一键切换脚本:
bash <(curl -sSL https://linuxmirrors.cn/main.sh)sudo apt update如果您使用Docker,也可以配置国内镜像加速器以加速容器镜像的拉取。
/etc/docker/daemon.json文件:sudo nano /etc/docker/daemon.json{ "registry-mirrors": ["https://docker.m.daocloud.io"]
}sudo systemctl restart docker通过以上步骤,您可以轻松地将Ubuntu软件源切换到国内镜像,从而加速软件的安装与更新。同时,配置Docker镜像加速器也可以提高Docker容器镜像的拉取速度。