ubuntu国内镜像源手动配置

备份当前源列表

打开终端,执行以下命令备份当前的源列表:

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

编辑源列表文件

使用文本编辑器编辑/etc/apt/sources.list文件,例如使用nano:

sudo vim /etc/apt/sources.list

添加或修改镜像源

将文件中的内容替换为适合的国内镜像源地址。例如,使用阿里云的镜像源,可以替换为:

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

注意:focal是Ubuntu 20.04的代号,根据你的Ubuntu版本,可能需要替换为bionic(Ubuntu 18.04)、xenial(Ubuntu 16.04)或其他代号。

更新软件包列表

保存并关闭编辑器后,更新软件包列表:

sudo apt update

你可能感兴趣的:(ubuntu,linux,运维)