apt-get命令配置source

时间:2024-04-10 17:31:46

问题描述:由于ubuntu 16.04版本中的apt source默认无法正常使用,在update命令时,出现如下的错误:

Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?

因此需要更新source,才能正常使用。

解决方法

1. 使用国内的镜像源:https://mirrors.tuna.tsinghua.edu.cn/help/ubuntu/。这里选择了16.04版本:apt-get命令配置source

2. 修改ubuntu中是source list:

[email protected]:~$ cd /etc/apt
[email protected]:/etc/apt$ sudo cp sources.list sources.list.bak
[email protected]:/etc/apt$ vim sources.list     

对source.list中的内容进行修改为如下内容:

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

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

3. 保存后,运行如下命令

[email protected]:/etc/apt$ sudo apt-get update 

4. 完成,可以使用apt-get命令下载所需的安装文件进行测试。