Ubuntu配置阿里云的apt源

root@zjy:~# cd /etc/apt/
root@zjy:/etc/apt# cp sources.list sources.list.bak
root@zjy:/etc/apt# >sources.list

注意:xenial为ubuntu系统的版本号。有关如何查看ubuntu版本请移步Ubuntu查看版本信息

root@zjy:/etc/apt# vim sources.list
deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
##测试版源  
deb http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse
# 源码  
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
##测试版源  
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse
# Canonical 合作伙伴和附加  
deb http://archive.canonical.com/ubuntu/ xenial partner
#deb http://extras.ubuntu.com/ubuntu/ xenial main  

upgrade报错

root@zjy:/etc/apt# apt-get upgrade
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Calculating upgrade... Done
The following packages have been kept back:
  cloud-init lxd lxd-client
The following packages will be upgraded:
  amd64-microcode ca-certificates intel-microcode liblxc-common liblxc1 libseccomp2 linux-base lxcfs snapd sosreport tcpdump tzdata unattended-upgrades wireless-regdb
14 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.
Need to get 25.0 MB of archives.
After this operation, 46.5 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://mirrors.aliyun.com/ubuntu xenial-security/main amd64 libseccomp2 amd64 2.4.3-1ubuntu3.16.04.3 [41.0 kB]
Get:2 http://mirrors.aliyun.com/ubuntu xenial-security/main amd64 tzdata all 2020d-0ubuntu0.16.04 [167 kB]
Get:3 http://mirrors.aliyun.com/ubuntu xenial-security/main amd64 linux-base all 4.5ubuntu1.2~16.04.1 [17.8 kB]
Get:4 http://mirrors.aliyun.com/ubuntu xenial-security/main amd64 ca-certificates all 20201027ubuntu0.16.04.1 [155 kB]
Get:5 http://mirrors.aliyun.com/ubuntu xenial-security/main amd64 tcpdump amd64 4.9.3-0ubuntu0.16.04.1 [363 kB]
Get:6 http://mirrors.aliyun.com/ubuntu xenial-backports/main amd64 liblxc-common amd64 3.0.3-0ubuntu1~16.04.1 [110 kB]
Get:7 http://mirrors.aliyun.com/ubuntu xenial-backports/main amd64 liblxc1 amd64 3.0.3-0ubuntu1~16.04.1 [264 kB]
Get:8 http://mirrors.aliyun.com/ubuntu xenial-backports/main amd64 lxcfs amd64 3.0.3-0ubuntu1~16.04.1 [38.6 kB]
Get:9 http://mirrors.aliyun.com/ubuntu xenial-updates/main amd64 snapd amd64 2.48 [20.8 MB]
Get:10 http://mirrors.aliyun.com/ubuntu xenial-updates/main amd64 sosreport amd64 3.9.1-1ubuntu0.16.04.1 [170 kB]                                                                           
Get:11 http://mirrors.aliyun.com/ubuntu xenial-updates/main amd64 unattended-upgrades all 1.1ubuntu1.18.04.7~16.04.6 [42.1 kB]                                                              
Get:12 http://mirrors.aliyun.com/ubuntu xenial-security/main amd64 wireless-regdb all 2020.11.20-0ubuntu1~16.04.2 [10.6 kB]                                                                 
Get:13 http://mirrors.aliyun.com/ubuntu xenial-security/main amd64 amd64-microcode amd64 3.20191021.1+really3.20180524.1~ubuntu0.16.04.2 [30.8 kB]                                          
Get:14 http://mirrors.aliyun.com/ubuntu xenial-security/main amd64 intel-microcode amd64 3.20201110.0ubuntu0.16.04.2 [2,743 kB]                                                             
Fetched 25.0 MB in 21s (1,211 kB/s)                                                                                                                                                         
Preconfiguring packages ...
(Reading database ... 66574 files and directories currently installed.)
Preparing to unpack .../libseccomp2_2.4.3-1ubuntu3.16.04.3_amd64.deb ...
Unpacking libseccomp2:amd64 (2.4.3-1ubuntu3.16.04.3) over (2.3.1-2.1ubuntu4) ...
Setting up libseccomp2:amd64 (2.4.3-1ubuntu3.16.04.3) ...
(Reading database ... 66574 files and directories currently installed.)
Preparing to unpack .../00-tzdata_2020d-0ubuntu0.16.04_all.deb ...
Unpacking tzdata (2020d-0ubuntu0.16.04) over (2018d-1) ...
Preparing to unpack .../01-linux-base_4.5ubuntu1.2~16.04.1_all.deb ...
Unpacking linux-base (4.5ubuntu1.2~16.04.1) over (4.5ubuntu1) ...
Preparing to unpack .../02-ca-certificates_20201027ubuntu0.16.04.1_all.deb ...
Unpacking ca-certificates (20201027ubuntu0.16.04.1) over (20180409) ...
Preparing to unpack .../03-tcpdump_4.9.3-0ubuntu0.16.04.1_amd64.deb ...
Unpacking tcpdump (4.9.3-0ubuntu0.16.04.1) over (4.9.2-3) ...
Preparing to unpack .../04-liblxc-common_3.0.3-0ubuntu1~16.04.1_amd64.deb ...
Unpacking liblxc-common (3.0.3-0ubuntu1~16.04.1) over (3.0.1-0ubuntu1~18.04.1) ...
Preparing to unpack .../05-liblxc1_3.0.3-0ubuntu1~16.04.1_amd64.deb ...
Unpacking liblxc1 (3.0.3-0ubuntu1~16.04.1) over (3.0.1-0ubuntu1~18.04.1) ...
Preparing to unpack .../06-lxcfs_3.0.3-0ubuntu1~16.04.1_amd64.deb ...
Unpacking lxcfs (3.0.3-0ubuntu1~16.04.1) over (3.0.1-0ubuntu2~18.04.1) ...
Preparing to unpack .../07-snapd_2.48_amd64.deb ...
Unpacking snapd (2.48) over (2.34.2+18.04) ...
Preparing to unpack .../08-sosreport_3.9.1-1ubuntu0.16.04.1_amd64.deb ...
Unpacking sosreport (3.9.1-1ubuntu0.16.04.1) over (3.5-1ubuntu3.18.04.1) ...
Preparing to unpack .../09-unattended-upgrades_1.1ubuntu1.18.04.7~16.04.6_all.deb ...
Unpacking unattended-upgrades (1.1ubuntu1.18.04.7~16.04.6) over (1.1ubuntu1.18.04.5) ...
Preparing to unpack .../10-wireless-regdb_2020.11.20-0ubuntu1~16.04.2_all.deb ...
Unpacking wireless-regdb (2020.11.20-0ubuntu1~16.04.2) over (2018.05.09-0ubuntu1~18.04.1) ...
dpkg: error processing archive /tmp/apt-dpkg-install-JN6Szw/10-wireless-regdb_2020.11.20-0ubuntu1~16.04.2_all.deb (--unpack):
 trying to overwrite '/lib/crda/pubkeys/sforshee.key.pub.pem', which is also in package crda 3.18-1build1
Preparing to unpack .../11-amd64-microcode_3.20191021.1+really3.20180524.1~ubuntu0.16.04.2_amd64.deb ...
Unpacking amd64-microcode (3.20191021.1+really3.20180524.1~ubuntu0.16.04.2) over (3.20180524.1~ubuntu0.18.04.1) ...
Preparing to unpack .../12-intel-microcode_3.20201110.0ubuntu0.16.04.2_amd64.deb ...
Unpacking intel-microcode (3.20201110.0ubuntu0.16.04.2) over (3.20180425.1~ubuntu0.18.04.1) ...
Errors were encountered while processing:
 /tmp/apt-dpkg-install-JN6Szw/10-wireless-regdb_2020.11.20-0ubuntu1~16.04.2_all.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
root@zjy:/etc/apt# apt-get upgrade
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Calculating upgrade... Done
The following packages have been kept back:
  cloud-init lxd lxd-client
The following packages will be upgraded:
  wireless-regdb
1 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.
12 not fully installed or removed.
Need to get 0 B/10.6 kB of archives.
After this operation, 1,024 B of additional disk space will be used.
Do you want to continue? [Y/n] y
(Reading database ... 66704 files and directories currently installed.)
Preparing to unpack .../wireless-regdb_2020.11.20-0ubuntu1~16.04.2_all.deb ...
Unpacking wireless-regdb (2020.11.20-0ubuntu1~16.04.2) over (2018.05.09-0ubuntu1~18.04.1) ...
dpkg: error processing archive /var/cache/apt/archives/wireless-regdb_2020.11.20-0ubuntu1~16.04.2_all.deb (--unpack):
 trying to overwrite '/lib/crda/pubkeys/sforshee.key.pub.pem', which is also in package crda 3.18-1build1
Errors were encountered while processing:
 /var/cache/apt/archives/wireless-regdb_2020.11.20-0ubuntu1~16.04.2_all.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

报错解决

root@zjy:/etc/apt# rm -rf /var/lib/dpkg/info/*
apt-get update 更新源  
apt-get upgrade 更新软件 
### 阿里云 APT 配置方法 为了提高基于 Ubuntu 的系统的软件包下载速度,可以通过更换为阿里云APT 来实现。以下是具体的配置过程: #### 1. 进入系统 APT 目录 首先需要进入 `/etc/apt` 文件夹,这是存储 APT 列表的地方。 ```bash cd /etc/apt/ ``` #### 2. 备份原始 `sources.list` 为了避免误操作导致无法恢复原状,在修改前先备份原有的 `sources.list` 文件。 ```bash sudo cp sources.list sources.list.bak ``` #### 3. 编辑 `sources.list` 使用文本编辑器打开 `sources.list` 并替换其中的内容为阿里云镜像地址。推荐使用 `gedit` 或者 `vi` 来完成此操作。 对于 **Ubuntu 20.04 LTS (Focal Fossa)**,可以将以下内容粘贴到文件中: ```plaintext 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-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-backports main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports 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 ``` 如果是其他版本(如 18.04, 16.04),可以根据官方文档调整 URL 中的代号[^2]。 #### 4. 更新 APT 软件包索引 保存更改后的 `sources.list` 后运行以下命令刷新本地缓存,使新配置生效。 ```bash sudo apt update ``` 如果一切正常,则会看到进度条以及成功消息;如果有错误提示,请仔细检查输入是否有错漏之处。 --- ### 注意事项 - 更改过程中务必小心谨慎,确保每一步都执行无误后再继续下一步。 - 如果不确定当前使用的具体发行版名称或者编号,可通过如下方式查询: ```bash lsb_release -a ``` ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

时空无限

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值