zoukankan      html  css  js  c++  java
  • Ubuntu配置apt安装源为清华源[含自动配置脚本]

    Ubuntu配置apt安装源为清华源[含自动配置脚本]

    一、备份原配置文件

    Ubuntu 的软件源配置文件是/etc/apt/sources.list。将系统自带的该文件做个备份,以防万一。

    sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak

    二、修改sources.list文件

    我习惯与使用vim编辑文件,如果你没有安装可以执行命令sudo apt-get install vim安装。

    清华ubuntu软件源配置帮助:https://mirrors.tuna.tsinghua.edu.cn/help/ubuntu/

    选择你系统对应版本,下面的就是需要你添加到sources.list文件中的内容。

    使用sudo vim /etc/apt/source.list打开文件,将文件原内容删除,添加在清华源获取的内容,保存。

    三、更新软件列表和软件源

    sudo apt-get update
    sudo apt-get upgrade

    四、 其他几个国内的软件源

    4.1 中国科技大学软件源

    中科大ubuntu软件源配置帮助: Ubuntu 源使用帮助 — USTC Mirror Help 文档

    以下是 Ubuntu 20.04 参考配置内容:

    # 默认注释了源码仓库,如有需要可自行取消注释
    deb https://mirrors.ustc.edu.cn/ubuntu/ focal main restricted universe multiverse
    # deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal main restricted universe multiverse
    
    deb https://mirrors.ustc.edu.cn/ubuntu/ focal-security main restricted universe multiverse
    # deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal-security main restricted universe multiverse
    
    deb https://mirrors.ustc.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
    # deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
    
    deb https://mirrors.ustc.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
    # deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
    
    # 预发布软件源,不建议启用
    # deb https://mirrors.ustc.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse
    # deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse

    4.2 阿里云软件源

    阿里云Ubuntu 18.04源,阿里云镜像站正在升级

    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
    

    五、脚本一键配置apt源

    示例为ubuntu18.04配置清华镜像源,其他版本或者其他源,做对应替换即可。

    #!/bin/bash
    #更新apt源为清华源
    echo "[Info] 正在备份默认apt源..."
    cp /etc/apt/sources.list /etc/apt/sources.list.bak
    echo "[Info] 正在替换apt源为清华apt源..."
    echo deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse > /etc/apt/sources.list
    echo deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse >> /etc/apt/sources.list
    echo deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse >> /etc/apt/sources.list
    echo deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse >> /etc/apt/sources.list
    echo "[Info] 正在更新源..."
    apt update
    echo "[Info] 正在更新软件..."
    apt upgrade -y
  • 相关阅读:
    TCP和UDP的一些区别: TCP提供可靠传输的机制:
    rpc和 http的区别
    熔断原理与实现Golang版
    源码解读 Golang 的 sync.Map 实现原理
    mysql底层为啥用b 树不用红黑树_MySQL索引底层数据结构
    一条sql 查询语句是如何执行的
    网络相关知识
    为什么遍历 Go map 是无序的?
    Go语言 参数传递究竟是值传递还是引用传递的问题分析
    解决goland debug 调试问题 Version of Delve is too old for this version of Go
  • 原文地址:https://www.cnblogs.com/lcxhk/p/14951334.html
Copyright © 2011-2022 走看看