zoukankan      html  css  js  c++  java
  • ubuntu apt 换阿里镜像源

    windows10自带ubuntu系统更新到ubuntu20.04版本啦!默认的软件更新源是国外的,速度超级慢,用"apt install"安装软件时各种网络问题也是层出不穷(上次安装ubuntu后忘记修改源结果导致N多次安装半小时然后失败.....亲身经历了这种苦,回过头发现修改源之后很多网络问题迎刃而解),因此我们需要更换成国内镜像源,然后正常安装和更新软件。

    unbuntu版本名
    修改源之前提示大家先查看版本名,ubuntu20.04对应的是“focal”,也就是我下面镜像源中提到的。“eoan”代表ubuntu19.10,“xenial”代表ubuntu16.04,“bionic”代表ubuntu18.04,“disco”代表ubuntu19.04,但是最好还是查看自己的版本名,并更改相应位置的ubuntu版本名。
    用以下命令查看版本名:

    lsb_release -c


    得到的就是你的版本名啦!比如我的就是:

    首先备份原来的软件源并另存:

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


    执行chmod命令更改文件权限使软件源文件可编辑:

    sudo chmod 777 /etc/apt/sources.list


    之后通过gedit命令编辑软件源:

    sudo gedit /etc/apt/sources.list


    如果报错提示:

    sudo: gedit: command not found


    那么直接使用vim修改:

    vim /etc/apt/sources.list


    顺便提一下vim的使用:进入后按i进入编辑模式(即INSERT插入),编辑完后先按Esc退出编辑模式,然后输入  :wq  退出即可。
    打开源文件后,进入编辑模式将所有的代码删干净,然后复制粘贴你需要的镜像源(下面的镜像源任选一个就可以,我用的是阿里云的镜像源,这里记得把ubuntu版本名替换为你在自己系统上查看到的版本名):

    编辑完后先按Esc退出编辑模式,输入  :wq  退出。
    **阿里云源:**

    复制代码
    deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
    
    deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
    
    deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
    
    deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
    
    deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
    
    deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
    
    deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
    
    deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
    
    deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
    
    deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
    复制代码


    **清华源**

    复制代码
    deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ eoan main restricted universe multiverse
    
    deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ eoan main restricted universe multiverse
    
    deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ eoan-updates main restricted universe multiverse
    
    deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ eoan-updates main restricted universe multiverse
    
    deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ eoan-backports main restricted universe multiverse
    
    deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ eoan-backports main restricted universe multiverse
    
    deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ eoan-security main restricted universe multiverse
    
    deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ eoan-security main restricted universe multiverse
    
    deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ eoan-proposed main restricted universe multiverse
    
    deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ eoan-proposed main restricted universe multiverse
    复制代码

    修改完软件源后,更新软件列表和软件:

    sudo apt update
    

    sudo apt upgrade

    然后大功告成!如果还有什么问题,留言与我交流!

    参考阿里官方源 18.04为bionic 20.04为focal https://developer.aliyun.com/mirror/ubuntu?spm=a2c6h.13651102.0.0.53322f70TiLYZU

  • 相关阅读:
    查询安装webpack4.0是否成功时提示无法找到的解决方法
    clientHeight—scrollHeight—offsetHeight三者的区别
    onunload事件不触发的探索
    你知道刷社保卡看病买药也能扫二维码支付吗?(以成都市社保卡为例)
    成都市新社保卡线上申请方法(无需线下办理,手机直接搞定)
    jquery实现移动端页面加载后,向上滚动指定距离无效引起的探索
    社保官网查询密码重置及注册(以成都为例)
    社保对线上购买保险时2个你不知道的影响(最后一个真的太坑爹,中招的人肯定不在少数)
    坑爹的京东E卡
    Mongodb(一)
  • 原文地址:https://www.cnblogs.com/ianlab/p/13771093.html
Copyright © 2011-2022 走看看