【Linux基础】Ubuntu系统换源

  • 欢迎各位读者:点赞 收藏 ⭐留言
  • 博客主页:https://blog.csdn.net/qq_59134387
  • 原创不易,转载请标明出处;如有错误,敬请指正批评!
  • 我不去想是否能够成功,既然选择了远方,便只顾风雨兼程!✨

文章目录

  • 前言
  • 一、换源目的
  • 二、换源步骤
  • 总结


前言

  本文将针对安装好的Ubuntu系统进行换源操作,将系统内的国外源更换为国内源(阿里源,网易源,清华源,中科大源等)。


一、换源目的

使用国外源弊端
         1.软件无法下载,找不到软件下载包
         2.容易出现下载错误,中途停止等情况
         3.使用国外的源下载 / 更新速度十分缓慢

   由于Ubuntu系统安装默认源为国外源(服务器位于国外),导致国内用户在开发的过程中会遇到一系列问题,为避免该系列问题,需要我们对安装好的Ubuntu系统进行换源操作。

二、换源步骤

源文件绝对路径: /etc/apt/sources.list

1.在终端使用管理员权限和gedit命令打开sources.list文件

终端命令:sudo gedit /etc/apt/source.list,打开文件后如下图所示:

【Linux基础】Ubuntu系统换源_第1张图片
2.将sources.list的内容替换为以下任意一段国内源

阿里源 Ubuntu 20.04版本

deb https://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
# deb https://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
# deb-src https://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse

清华源 Ubuntu 20.04版本

# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse

# 预发布软件源,不建议启用
# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse

中科大源 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-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-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-proposed main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse

3.更新缓存和升级(更新源)

终端命令:sudo apt-get update (更新源)


总结

   以上就是【Linux基础】Ubuntu系统换源的所有内容,希望大家阅读后都能有所收获!原创不易,转载请标明出处,若文章出现有误之处,欢迎读者留言指正批评!

你可能感兴趣的:(Linux,基础学习,ubuntu,linux,服务器)