1-ubuntu基础——换源第一步

本文详细介绍了在Ubuntu操作系统上如何进行换源操作,以提高软件下载速度。首先备份默认源,然后使用gedit编辑器替换为阿里云镜像源。根据系统版本(如Ubuntu 22.04 LTS的jammy源)选择正确的镜像链接,并通过`apt-get update`和`apt-get upgrade`命令更新系统。正确执行后,将实现顺利的软件包管理和系统升级。
摘要由CSDN通过智能技术生成

1、换源第一步

安装好ubuntu操作系统之后的第一步就是换源!!!

由于墙的原因,后续我们需要使用各种命令去下载东西,为了下载方便,这里我们提前换源。

1.1 备份系统默认源

第一个参数时拷贝的文件路径和文件名称,第二个是拷贝到(粘贴)的文件路径和文件名

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

1.2 使用gedit编辑文件换源

由于还没有换源,加上系统可能没有vim软件,这个时候我们可以用ubuntu自带的gedit编辑器打开,然后江sources.list文件里的内容清空,再复制相应的国内源进去。

gedit 编辑器打开代码:

sudo gedit /etc/apt/sources.list

这个时候我们可以从网上找到相应的国内源,如常见的是阿里源、清华源、中科大源,这里我给出阿里源,我自己使用的:

#添加阿里源
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-backports main restricted universe multiverse

注意!!!!
上面的源也是有区分的,我也是后面报错了才知道。可以看到,上面的的源都有一个叫做focal的单词,这取决于你的系统是focal还是bionic,去网上找一下,有相应的命令。
还有的源是bionic:

1.3 查看Ubuntu的系统源

lsb_release -a

输出的是如下:

No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 22.04 LTS
Release:	22.04
Codename:	jammy
cowa@cowa-NUC11PAHi5:/etc

也就是说,我这个系统是jammy源,那么,我就要找到jammy源换上去。

deb http://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse

# deb http://mirrors.aliyun.com/ubuntu/ jammy-proposed main restricted universe multiverse
# deb-src http://mirrors.aliyun.com/ubuntu/ jammy-proposed main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse
#阿里源
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

sudo apt-get update
#这个命令,会访问源列表里的每个网址,并读取软件列表,然后保存在本地电脑。我们在新立得软件包管理器里看到的软件列表,都是通过update命令更新的。

sudo apt-get upgrade
#这个命令,会把本地已安装的软件,与刚下载的软件列表里对应软件进行对比,如果发现已安装的软件版本太低,就会提示你更新。如果你的软件都是最新版本,会提示:
  		#升级了 0 个软件包,新安装了 0 个软件包,要卸载 0 个软件包,有 0 个软件包未被升级。

上面如果没用报错【E,W】开头啥的错误的话,就表示换源成功,此时可以好好安装。

  • 18
    点赞
  • 62
    收藏
    觉得还不错? 一键收藏
  • 9
    评论
评论 9
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值