Debian12换镜像源

0 背景

用docker运行了一个node容器,发现连vim也没有,所以打算安一个vim

1 查看操作系统

find / -name '*release*' #查看release信息

Debian12换镜像源_第1张图片
Debian12换镜像源_第2张图片

2 更换镜像源

2.1 从网上找个国内镜像源

确定好操作系统版本后,从网上搜一下对应的数据源。这里提供一个清华的源

deb https://mirrors.tuna.tsinghua.edu.cn/debian/ buster main contrib non-free
deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ buster main contrib non-free
 
deb https://mirrors.tuna.tsinghua.edu.cn/debian-security/ buster/updates main contrib non-free
deb-src https://mirrors.tuna.tsinghua.edu.cn/debian-security/ buster/updates main contrib non-free
 
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ buster-updates main contrib non-free
deb-src 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-src https://mirrors.tuna.tsinghua.edu.cn/debian/ buster-backports main contrib non-free

2.2 写入配置文件

切换目录到/etc/apt下
因为没有vim,不能直接复制粘贴,所以可以用重定向写入source.list

echo 'deb https://mirrors.tuna.tsinghua.edu.cn/debian/ buster main contrib non-free
deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ buster main contrib non-free

deb https://mirrors.tuna.tsinghua.edu.cn/debian-security/ buster/updates main contrib non-free
deb-src https://mirrors.tuna.tsinghua.edu.cn/debian-security/ buster/updates main contrib non-free

deb https://mirrors.tuna.tsinghua.edu.cn/debian/ buster-updates main contrib non-free
deb-src 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-src https://mirrors.tuna.tsinghua.edu.cn/debian/ buster-backports main contrib non-free' > sources.list

2.3 更新

apt-get update

注:这样镜像源就换好了,如果你发现还是有国外的源在更新,可以把原来的文件名改掉(sources.list.d文件夹下的文件随便加个后缀就行)

3 后记

如果你安装vim发现报错,vim-common版本有问题之类的报错,可以参考这个文章

你可能感兴趣的:(linux,debian,镜像源)