Ubuntu更新源

一、sudo apt-get update命令

在Debian系中,Ubuntu是很火的一款开源系统产品。使用sudo apt-get update从我们的更新源中获取并更新系统中软件包的列表信息,sudo apt-get update作用如下:

  1. 更新软件包列表: 将本地软件包列表与远程仓库中的最新列表同步,这样系统就可以了解到所有可用的软件包及其版本信息。

  2. 获取最新版本信息: 更新操作会检查每个软件包的最新版本号和依赖关系,确保系统中的软件包信息是最新的。

  3. 修复软件包索引问题: 有时候软件包索引可能过时或损坏,运行 sudo apt-get update 可以修复这些问题,使得后续的软件包安装和升级操作能够正常进行。

二、Ubuntu存放源的文件

 在Ubuntu中,我们使用各种各样的工具和依赖包都需要从更新源获取并下载下来,然后安装之后才能使用。传统的更新源文件指定在/ect/apt/目录下,传统的更新源文件名称:sources.list

更新源的两种格式

1、传统格式(/etc/apt/sources.list

2、DEB822 格式(/etc/apt/sources.list.d/ubuntu.sources

今天我遇到了这么一个问题,我想安装net-tools工具,使用传统的ifconfig命令查看ip地址,但是工具安装不了,问题如下:

sudo apt-get install net-tools  //安装net-tools,因为更新源被拒绝了需要换个源
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following NEW packages will be installed:
  net-tools
0 upgraded, 1 newly installed, 0 to remove and 87 not upgraded.
Need to get 204 kB of archives.
After this operation, 819 kB of additional disk space will be used.
Ign:1 http://cn.archive.ubuntu.com/ubuntu jammy/main amd64 net-tools amd64 1.60+git20181103.0eebece-1ubuntu5
Ign:1 http://cn.archive.ubuntu.com/ubuntu jammy/main amd64 net-tools amd64 1.60+git20181103.0eebece-1ubuntu5
Ign:1 http://cn.archive.ubuntu.com/ubuntu jammy/main amd64 net-tools amd64 1.60+git20181103.0eebece-1ubuntu5
Err:1 http://cn.archive.ubuntu.com/ubuntu jammy/main amd64 net-tools amd64 1.60+git20181103.0eebece-1ubuntu5
  Cannot initiate the connection to cn.archive.ubuntu.com:80 (2403:2c80:5::6). - connect (101: Network is unreachable) Could not connect to cn.archive.ubuntu.com:80 (45.125.0.6). - connect (111: Connection refused)
E: Failed to fetch http://cn.archive.ubuntu.com/ubuntu/pool/main/n/net-tools/net-tools_1.60%2bgit20181103.0eebece-1ubuntu5_amd64.deb  Cannot initiate the connection to cn.archive.ubuntu.com:80 (2403:2c80:5::6). - connect (101: Network is unreachable) Could not connect to cn.archive.ubuntu.com:80 (45.125.0.6). - connect (111: Connection refused)
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?

我想安装原来的Index of /ubuntu/ | 清华大学开源软件镜像站 | Tsinghua Open Source Mirror这个被拒绝了,很麻烦,获取不到来自更新源所在仓库的工具和依赖包。没办法要么自己搭建仓库存储各种各样的工具和依赖包。。。要么更换源。我选换源!

 sudo apt-get update //被拒绝
Hit:1 http://security.ubuntu.com/ubuntu jammy-security InRelease
Ign:2 http://cn.archive.ubuntu.com/ubuntu jammy InRelease
Ign:3 http://cn.archive.ubuntu.com/ubuntu jammy-updates InRelease
Ign:4 http://cn.archive.ubuntu.com/ubuntu jammy-backports InRelease
Ign:2 http://cn.archive.ubuntu.com/ubuntu jammy InRelease
Ign:3 http://cn.archive.ubuntu.com/ubuntu jammy-updates InRelease
Ign:4 http://cn.archive.ubuntu.com/ubuntu jammy-backports InRelease
Ign:2 http://cn.archive.ubuntu.com/ubuntu jammy InRelease
Ign:3 http://cn.archive.ubuntu.com/ubuntu jammy-updates InRelease
Ign:4 http://cn.archive.ubuntu.com/ubuntu jammy-backports InRelease
Err:2 http://cn.archive.ubuntu.com/ubuntu jammy InRelease
  Cannot initiate the connection to cn.archive.ubuntu.com:80 (2403:2c80:5::6). - connect (101: Network is unreachable) Could not connect to cn.archive.ubuntu.com:80 (45.125.0.6). - connect (111: Connection refused)
Err:3 http://cn.archive.ubuntu.com/ubuntu jammy-updates InRelease
  Cannot initiate the connection to cn.archive.ubuntu.com:80 (2403:2c80:5::6). - connect (101: Network is unreachable)
Err:4 http://cn.archive.ubuntu.com/ubuntu jammy-backports InRelease
  Cannot initiate the connection to cn.archive.ubuntu.com:80 (2403:2c80:5::6). - connect (101: Network is unreachable)
Reading package lists... Done
W: Failed to fetch http://cn.archive.ubuntu.com/ubuntu/dists/jammy/InRelease  Cannot initiate the connection to cn.archive.ubuntu.com:80 (2403:2c80:5::6). - connect (101: Network is unreachable) Could not connect to cn.archive.ubuntu.com:80 (45.125.0.6). - connect (111: Connection refused)
W: Failed to fetch http://cn.archive.ubuntu.com/ubuntu/dists/jammy-updates/InRelease  Cannot initiate the connection to cn.archive.ubuntu.com:80 (2403:2c80:5::6). - connect (101: Network is unreachable)
W: Failed to fetch http://cn.archive.ubuntu.com/ubuntu/dists/jammy-backports/InRelease  Cannot initiate the connection to cn.archive.ubuntu.com:80 (2403:2c80:5::6). - connect (101: Network is unreachable)
W: Some index files failed to download. They have been ignored, or old ones used instead.

三、更新源

从网上我搜集了国内的三所名牌大学和四个知名企业的Ubuntu源地址(家大业大,不容易倒闭,稳的一批)

ubuntu | 镜像站使用帮助 | 清华大学开源软件镜像站 | Tsinghua Open Source Mirror

帮助-北京大学开源镜像站 (pku.edu.cn)

中国科学技术大学:Ubuntu - USTC Mirror Help

ubuntu镜像_ubuntu下载地址_ubuntu安装教程-阿里巴巴开源镜像站 (aliyun.com)

华为开源镜像站_软件开发服务_华为云 (huaweicloud.com)

腾讯云开源镜像站上线啦! (tencent.com)//腾讯老大哥源更新文档不及时,不推荐

Ubuntu官方源:Ubuntu | 全球领先的用于个人电脑、平板及手机的操作系统//一般不推荐,没办法国内外互联网走不通,网卡的一批

这里我直接使用传统格式重新更换了新的清华大学的源(ubuntu | 镜像站使用帮助 | 清华大学开源软件镜像站 | Tsinghua Open Source Mirror),直接把源地址中的如下红框截图的部分全部copy到:/etc/apt/sources.list文件中,把原来的内容全部注释或删除即可。(细节:一定要有root权限,或者sudo获取root权限)

 四、更新索引

sudo apt-get update,成功更新源

最后我再试试sudo apt-get install net-tools,成功安装!

 ifconfig命令也成功显示了IP地址,Over!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值