配置linux软件仓库的核心是修改系统源地址文件以提升更新速度。1.备份原有配置文件避免出错;2.编辑源地址文件替换为新镜像源内容如清华大学或阿里云源;3.根据系统类型更新包列表如debian/ubuntu用apt update,rhel/centos/fedora用yum或dnf makecache;4.可选执行升级命令更新软件包。操作流程清晰且适用于不同发行版系统。

Linux软件仓库配置,说白了,就是给你的系统指明一个下载软件和更新的地址。这事儿听起来简单,但选对了镜像源,你的系统更新速度能快得飞起,选错了,可能就得盯着进度条发呆了。国内外常用镜像源的选择,其实就是一场速度、稳定性和资源完整度的博弈。

要配置Linux的软件仓库,核心操作无非就是修改系统里存放源地址的那个文件。不同发行版文件位置和格式略有不同,但思路都一样:备份旧的,替换成新的,然后更新一下包列表。
以Debian/Ubuntu系为例,主要修改
/etc/apt/sources.list

备份原有配置文件:
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
这步很重要,万一改错了还能退回去。我个人习惯,任何重要的配置文件修改前都先备份一下。
编辑sources.list文件: 你可以用你喜欢的文本编辑器,比如
nano
vim
sudo nano /etc/apt/sources.list
清空原有内容(或者注释掉,用
#
deb 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 # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse
(注意:
focal
对于RHEL/CentOS/Fedora系,通常是在
/etc/yum.repos.d/
/etc/dnf/repos.d/
.repo
sudo sed -e 's|^mirrorlist=|#mirrorlist=|g' \
-e 's|^#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/|baseurl=https://mirrors.aliyun.com/centos/$releasever/os/$basearch/|g' \
-i.bak /etc/yum.repos.d/CentOS-Base.repo这个命令直接把官方的
mirrorlist
baseurl
更新软件包列表: Debian/Ubuntu:
sudo apt update
RHEL/CentOS/Fedora:
sudo yum makecache # 或者 sudo dnf makecache
这步是让系统知道你换了新地址,然后去新地址把最新的软件包列表拉回来。如果这一步报错,那前面的配置可能就有问题了。
升级软件包(可选但推荐): Debian/Ubuntu:
sudo apt upgrade
RHEL/Cent
以上就是Linux软件仓库配置_Linux国内外常用镜像源选择与配置的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号