Linux设置国内镜像源其实很简单,只要一行命令
相信大伙们在安装完Linux的第一件事情就是要设置一下镜像源了吧!
很多人第一次设置镜像源,当然是在网上找教程了。然而网上的教程一看,哇~怎么这么复杂!他说的那个文件我都找不到,又得找半天。找到要文件之后呢,修改了文件内容,保存。接着就是一堆莫名其妙的代码,做什么用的当然也不知道,因为没用过那些命令,只能照着在终端输入了进去,sudo rm -rf /* 也不例外。
其实,一行命令就可以自动设置国内的镜像源。我们来看看:
我所用的系统是Manjaro,执行以下命令
sudo pacman-mirrors -c China
然后输出了这一堆信息
[wu@wu-invalid ~]$ sudo pacman-mirrors -c China
::INFO Downloading mirrors from repo.manjaro.org
::INFO User generated mirror list
::------------------------------------------------------------
::INFO Custom mirror file saved: /var/lib/pacman-mirrors/custom-mirrors.json
::INFO Using custom mirror file
::INFO Querying mirrors - This may take some time
0.443 China : https://mirrors.huaweicloud.com/manjaro/
0.315 China : http://mirrors.huaweicloud.com/manjaro/
0.363 China : https://mirrors.aliyun.com/manjaro/
0.354 China : https://mirrors.ustc.edu.cn/manjaro/
0.631 China : https://mirrors.tuna.tsinghua.edu.cn/manjaro/
1.601 China : https://mirrors.tuna.tsinghua.edu.cn/manjaro/
0.478 China : https://mirrors.sjtug.sjtu.edu.cn/manjaro/
::INFO Writing mirror list
::China : https://mirrors.huaweicloud.com/manjaro/stable/$repo/$arch
::China : https://mirrors.ustc.edu.cn/manjaro/stable/$repo/$arch
::China : https://mirrors.aliyun.com/manjaro/stable/$repo/$arch
::China : https://mirrors.sjtug.sjtu.edu.cn/manjaro/stable/$repo/$arch
::China : https://mirrors.tuna.tsinghua.edu.cn/manjaro/stable/$repo/$arch
::China : https://mirrors.tuna.tsinghua.edu.cn/manjaro/stable/$repo/$arch
::INFO Mirror list generated and saved to: /etc/pacman.d/mirrorlist
::INFO To reset custom mirrorlist 'sudo pacman-mirrors -id'
::INFO To remove custom config run 'sudo pacman-mirrors -c all'
从信息中可以看出,系统找到了好几个国内的镜像源,然后将它们写入到了/etc/pacman.d/mirrorlist文件中,我们打开这个文件看下
以下是该文件内容
##
## Manjaro Linux custom mirrorlist
## Generated on 2021-01-23 10:09
##
## Please use 'pacman-mirrors -id' To reset custom mirrorlist
## Please use 'pacman-mirrors -c all' To reset custom mirrorlist
## To remove custom config run 'pacman-mirrors -c all'
##
## Country : China
Server = https://mirrors.huaweicloud.com/manjaro/stable/$repo/$arch
## Country : China
Server = https://mirrors.ustc.edu.cn/manjaro/stable/$repo/$arch
## Country : China
Server = https://mirrors.aliyun.com/manjaro/stable/$repo/$arch
## Country : China
Server = https://mirrors.sjtug.sjtu.edu.cn/manjaro/stable/$repo/$arch
## Country : China
Server = https://mirrors.tuna.tsinghua.edu.cn/manjaro/stable/$repo/$arch
## Country : China
Server = https://mirrors.tuna.tsinghua.edu.cn/manjaro/stable/$repo/$arch