当前位置:   article > 正文

ubuntu18.04 | 配置apt国内镜像源_ubuntu18.04镜像

ubuntu18.04镜像

一、为什么要重新配置国内镜像源

  配置apt国内镜像源可以加快软件包的下载速度,提高软件安装的效率。如果使用默认的官方源,由于网络原因,下载速度可能会很慢,甚至无法下载。而使用国内的镜像源,可以避免这些问题,提高软件下载的速度和成功率。

二、配置步骤

  1. 首先,先备份旧的源(在修改文件前先备份文件是一个好的习惯)

    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 87 14:18 /etc/apt/sources.list
    -rw-r--r-- 1 root root 2886 119 23:48 /etc/apt/sources.list.bak
    -rw-rw-r-- 1 root root 2906 87 14:18 /etc/apt/sources.list.save
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
  2. 设置新的镜像源

    root@liujie-virtual-machine-18:/home/liujie# vim /etc/apt/sources.list
    
    • 1
  3. 将默认的源删除掉,添加国内的镜像源,例如:清华源、阿里源、中科大源等

    在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
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8

    阿里源

    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
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10

    中科大源

    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
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10

    没有必要全部添加,选择一个即可

  4. 更新软件包列表并升级已安装的软件包

    root@liujie-virtual-machine-18:/home/liujie# apt-get update
    
    • 1
    root@liujie-virtual-machine-18:/home/liujie# apt-get upgrade
    
    • 1
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/菜鸟追梦旅行/article/detail/527732
推荐阅读
相关标签
  

闽ICP备14008679号