Ubuntu切换数据源

简介: Ubuntu安装完毕之后,默认的源是Ubuntu自己的,但毕竟Ubuntu服务器在国外,我们访问起来会比较慢,可以将软件源切换为国内源,比如:阿里源,清华源,中科大源等等。在这边以清华源为例,其它源也是一样的道理。

Ubuntu安装完毕之后,默认的源是Ubuntu自己的,但毕竟Ubuntu服务器在国外,我们访问起来会比较慢,可以将软件源切换为国内源,比如:阿里源,清华源,中科大源等等。在这边以清华源为例,其它源也是一样的道理。


1 切换源之前先把配置文件备份一份:

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


2 找到清华源官网:

https://mirrors.tuna.tsinghua.edu.cn/help/ubuntu/


一定要选择与自己版本相对应的源,比如当前使用Ubuntu20.04,最好使用此版本的源,否则有可能会有意料不到的问题,良许就吃过这方面的亏。


image.png


网络上也有很多教你换源的帖子,但都是直接给出内容,有可能源与自己的版本不一致,所以最好自己去官网复制。


3.将之前的源全部删除

echo ” > sources.list


4.编辑新源文件

nano sources.list


5.加入新的数据源(清华数据源)

# 默认注释了源码镜像以提高 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

6.使用新源替换掉原来的源(一定要加sudo):

sudo vi /etc/apt/sources.list


7.然后更新软件包缓存:

sudo apt update


这个命令,会访问源列表里的每个网址,并读取软件列表,然后保存在本地电脑。


8.通常我们会紧跟着再执行命令:

sudo apt-get upgrade


这个命令,会把本地已安装的软件,与刚下载的软件列表里对应软件进行对比,如果发现已安装的软件版本太低,就会提示你更新。


9.备用数据源【阿里】

在下面网站查找最新数据源


https://developer.aliyun.com/mirror/ubuntu?spm=a2c6h.13651102.0.0.b5371b11tio0iu


Ubuntu 14.04.5 LTS为例,最后的效果如下:

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

ubuntu 16.04 配置如下

deb http://mirrors.aliyun.com/ubuntu/ xenial main
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main
deb http://mirrors.aliyun.com/ubuntu/ xenial universe
deb-src http://mirrors.aliyun.com/ubuntu/ xenial universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main
deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security universe

ubuntu 18.04(bionic) 配置如下

deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src 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-backports main restricted universe multiverse

ubuntu 20.04(focal) 配置如下

deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb-src 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-backport
相关文章
|
Ubuntu C++
Ubuntu20.04(LTS)换源(阿里、清华)以及sources.list分享
自用好使,谨慎操作 鄙人在安装完Ubuntu之后,安装Code::blocks的时候,在此之前需要安装C/C++编译环境build-essential,在安装的时候报出有关软件包依赖性的关系问题,经过一波研究发现,有的大佬通过安装aptitude来解决问题,因为aptitude可以很好地解决依赖关系 但是在安装aptitude的时候,还是出现了依赖关系,莫得办法 安装aptitude的命令
8957 0
|
9月前
|
Linux API iOS开发
彻底卸载OpenClaw与Ollama完整教程(附阿里云/MacOS/Linux/Windows部署OpenClaw与API配置指南)
在2026年的AI本地部署生态中,OpenClaw(Clawdbot)与Ollama依然是轻量化AI智能体与本地大模型运行的主流组合。但随着版本迭代、环境冲突、服务残留、响应卡顿等问题出现,许多用户需要重新部署、切换方案或彻底清理环境。不完整的卸载会导致端口占用、服务自启、配置冲突、磁盘垃圾堆积等问题,直接影响后续重新安装的成功率。
6343 0
|
9月前
|
Linux API 数据安全/隐私保护
保姆级图文教程:零基础OpenClaw阿里云/本地部署配置免费大模型API+集成QQ/企业微信及常见问题解答
OpenClaw(曾用名Clawdbot,昵称“小龙虾”)作为2026年热门的开源AI智能体平台,核心价值在于能将自然语言指令转化为实际操作,涵盖文件处理、程序控制、流程自动化等多种场景,无需用户具备编程基础。对于零基础用户而言,部署OpenClaw的核心需求的是“简单易操作、稳定可复用”,而阿里云部署可实现7×24小时稳定运行、多设备远程访问,本地部署则保障数据私有化,再结合QQ、企业微信接入,能让AI智能体融入日常沟通场景,大幅提升效率。
2129 131
|
8月前
|
Rust Ubuntu 安全
Ubuntu 26.04 LTS (Resolute Raccoon) 正式版发布
Ubuntu 26.04 LTS (Resolute Raccoon) 正式版发布 - 现代化的企业与开源 Linux
3538 2
Ubuntu 26.04 LTS (Resolute Raccoon) 正式版发布
|
Ubuntu Linux 数据安全/隐私保护
Beta 版 Ubuntu 24.04 LTS 镜像开放下载:GNOME 46 + Linux 6.8
IT之家附上镜像下载地址:Beta 版 Ubuntu 24.04 LTS
|
Ubuntu 机器人 项目管理
Ubuntu系统更换软件源以及ROS包管理问题解析
以上是针对Ubuntu系统软件源的更换和ROS包管理的关键步骤。务必跟随官方指南,在安装或者配置过程中应答疑解惑,确保每一步操作的准确性。这些操作对于机器人研发人员和爱好者来说是日常任务的一部分,熟练掌握这些技能,能够在机器人编程和项目管理方面提供很大的帮助。
1065 0
|
并行计算 PyTorch TensorFlow
Ubuntu安装笔记(一):安装显卡驱动、cuda/cudnn、Anaconda、Pytorch、Tensorflow、Opencv、Visdom、FFMPEG、卸载一些不必要的预装软件
这篇文章是关于如何在Ubuntu操作系统上安装显卡驱动、CUDA、CUDNN、Anaconda、PyTorch、TensorFlow、OpenCV、FFMPEG以及卸载不必要的预装软件的详细指南。
13126 4