一、为什么要重新配置国内镜像源
配置apt国内镜像源可以加快软件包的下载速度,提高软件安装的效率。如果使用默认的官方源,由于网络原因,下载速度可能会很慢,甚至无法下载。而使用国内的镜像源,可以避免这些问题,提高软件下载的速度和成功率。
二、配置步骤
-
首先,先备份旧的源(在修改文件前先备份文件是一个好的习惯)
liujie@liujie-virtual-machine-18:~$ sudo su [sudo] liujie 的密码: root@liujie-virtual-machine-18:/home/liujie# sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak root@liujie-virtual-machine-18:/home/liujie# ls -l /etc/apt/sources.list* -rw-rw-r-- 1 root root 2886 8月 7 14:18 /etc/apt/sources.list -rw-r--r-- 1 root root 2886 11月 9 23:48 /etc/apt/sources.list.bak -rw-rw-r-- 1 root root 2906 8月 7 14:18 /etc/apt/sources.list.save
-
设置新的镜像源
root@liujie-virtual-machine-18:/home/liujie# vim /etc/apt/sources.list
-
将默认的源删除掉,添加国内的镜像源,例如:清华源、阿里源、中科大源等
在vim中删除文件中所有内容的指令是
:1,$d
其中,:
表示进入命令模式,1,$
表示从第一行到最后一行,d
表示删除。执行该指令后,文件中所有内容都会被删除。清华源:
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
阿里源:
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
中科大源:
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
没有必要全部添加,选择一个即可文章来源:https://www.toymoban.com/news/detail-771845.html
-
更新软件包列表并升级已安装的软件包文章来源地址https://www.toymoban.com/news/detail-771845.html
root@liujie-virtual-machine-18:/home/liujie# apt-get update
root@liujie-virtual-machine-18:/home/liujie# apt-get upgrade
到了这里,关于ubuntu18.04 | 配置apt国内镜像源的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!