linux系统install安装/update更新软件报错

系统介绍

  • 作者使用Debian9标准版系统,使用系统默认“中科大”软件源:

/etc/apt/source.list路径下

deb http://mirrors.ustc.edu.cn/debian stable main contrib non-free
deb-src http://mirrors.ustc.edu.cn/debian stable main contrib non-free
deb http://mirrors.ustc.edu.cn/debian stable-updates main contrib non-free
deb-src http://mirrors.ustc.edu.cn/debian stable-updates main contrib non-free
deb http://mirrors.ustc.edu.cn/debian stable-proposed-updates main contrib non-free
deb-src http://mirrors.ustc.edu.cn/debian stable-proposed-updates main contrib non-free
  • DNS域名解析配置文件

/etc/resolv.conf路径下

# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 192.168.1.1
nameserver 127.0.0.53
search lan
nameserver 8.8.8.8

遇到问题1

  • 使用sudo apt-get update遇到错误,没有公钥NO_PUBKEY
忽略:1 http://mirrors.ustc.edu.com/debian stretch InRelease
命中:2 http://mirrors.ustc.edu.com/debian-security stretch/updates InRelease
命中:3 http://mirrors.ustc.edu.com/debian stretch-updates InRelease
错误:2 http://mirrors.ustc.edu.com/debian-security stretch/updates InRelease
  由于没有公钥,无法验证下列签名: NO_PUBKEY AA8E81B4331F7F50 NO_PUBKEY 112695A0E562B32A
命中:4 http://mirrors.ustc.edu.com/debian stretch Release
错误:3 http://mirrors.ustc.edu.com/debian stretch-updates InRelease
  由于没有公钥,无法验证下列签名: NO_PUBKEY 04EE7237B7D453EC NO_PUBKEY 648ACFD622F3D138
错误:5 http://mirrors.ustc.edu.com/debian stretch Release.gpg
  由于没有公钥,无法验证下列签名: NO_PUBKEY 04EE7237B7D453EC NO_PUBKEY 648ACFD622F3D138 NO_PUBKEY 0E98404D386FA1D9 NO_PUBKEY EF0F382A1A7B6500

解决方案1

  • 尝试了网上好多办法,gpg 下载key都不行;最后发现 更新debian-archive-keyring这个软件包,就一切问题解决了
    安装新版本debian-archive-keyring。
sudo apt-get install debian-archive-keyring

遇到问题2

  • sudo apt-get install 软件名安装软件时报错
W: Failed to fetch http://security.ustc.edu.com/ubuntu/dists/precise-security/main/source/Sources  404  Not Found [IP: 91.189.91.39 80]
W: Failed to fetch http://us.archive.ustc.edu.com/ubuntu/dists/precise/main/source/Sources  404  Not Found [IP: 91.189.91.38 80]
W: Failed to fetch http://us.archive.ustc.edu.com/ubuntu/dists/precise/universe/source/Sources  404  Not Found [IP: 91.189.91.38 80]
W: Failed to fetch http://us.archive.ustc.edu.com/ubuntu/dists/precise/universe/binary-i386/Packages  404  Not Found [IP: 91.189.91.38 80]
W: Failed to fetch http://us.archive.ustc.edu.com/ubuntu/dists/precise/multiverse/binary-i386/Packages  404  Not Found [IP: 91.189.91.38 80]
W: Failed to fetch http://security.ustc.edu.com/ubuntu/dists/precise-security/restricted/source/Sources  404  Not Found [IP: 91.189.91.39 80]
W: Failed to fetch http://security.ustc.edu.com/ubuntu/dists/precise-security/universe/source/Sources  404  Not Found [IP: 91.189.91.39 80]
W: Failed to fetch http://security.ustc.edu.com/ubuntu/dists/precise-security/multiverse/source/Sources  404  Not Found [IP: 91.189.91.39 80]

解决方案2

  • 更换软件源即可,然后sudo apt-get update更新本地仓库软件列表,再去安装即可
# Debian 10 buster

# 中科大源

#deb http://mirrors.ustc.edu.cn/debian buster main contrib non-free
#deb http://mirrors.ustc.edu.cn/debian buster-updates main contrib non-free
#deb http://mirrors.ustc.edu.cn/debian buster-backports main contrib non-free
#deb http://mirrors.ustc.edu.cn/debian-security/ buster/updates main contrib non-free

# deb-src http://mirrors.ustc.edu.cn/debian buster main contrib non-free
# deb-src http://mirrors.ustc.edu.cn/debian buster-updates main contrib non-free
# deb-src http://mirrors.ustc.edu.cn/debian buster-backports main contrib non-free
# deb-src http://mirrors.ustc.edu.cn/debian-security/ buster/updates main contrib non-free

# 官方源

# deb http://deb.debian.org/debian buster main contrib non-free
# deb http://deb.debian.org/debian buster-updates main contrib non-free
# deb http://deb.debian.org/debian-security/ buster/updates main contrib non-free

# deb-src http://deb.debian.org/debian buster main contrib non-free
# deb-src http://deb.debian.org/debian buster-updates main contrib non-free
# deb-src http://deb.debian.org/debian-security/ buster/updates main contrib non-free

# 网易源

# deb http://mirrors.163.com/debian/ buster main non-free contrib
# deb http://mirrors.163.com/debian/ buster-updates main non-free contrib
# deb http://mirrors.163.com/debian/ buster-backports main non-free contrib
# deb http://mirrors.163.com/debian-security/ buster/updates main non-free contrib

# deb-src http://mirrors.163.com/debian/ buster main non-free contrib
# deb-src http://mirrors.163.com/debian/ buster-updates main non-free contrib
# deb-src http://mirrors.163.com/debian/ buster-backports main non-free contrib
# deb-src http://mirrors.163.com/debian-security/ buster/updates main non-free contrib

# 阿里云

deb https://mirrors.aliyun.com/debian/ bullseye main non-free contrib
deb-src https://mirrors.aliyun.com/debian/ bullseye main non-free contrib
deb https://mirrors.aliyun.com/debian-security/ bullseye-security main
deb-src https://mirrors.aliyun.com/debian-security/ bullseye-security main
deb https://mirrors.aliyun.com/debian/ bullseye-updates main non-free contrib
deb-src https://mirrors.aliyun.com/debian/ bullseye-updates main non-free contrib
deb https://mirrors.aliyun.com/debian/ bullseye-backports main non-free contrib
deb-src https://mirrors.aliyun.com/debian/ bullseye-backports main non-free contrib
  • 还有一种情况是DNS域名解析服务用不了,每一个不同的源,要适配不同的DNS解析地址

/etc/resolv.conf路径下

# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
#阿里云DNS
nameserver 127.0.0.53
nameserver 8.8.8.8

#中科大DNS
#nameserver 202.141.162.123
#nameserver 202.141.178.13
#nameserver 202.38.93.153
#nameserver 202.141.176.93

查看linux系统是否可以正确访问软件源

  • 在terminal终端ping软件源网址,如果能ping通,说明软件源可以访问。
ping http://mirrors.ustc.edu.cn/debian
ping https://mirrors.aliyun.com/debian/

使用update和upgrade注意事项

  • update

update 是同步 /etc/apt/sources.list 和 /etc/apt/sources.list.d 中列出的源的索引,获取到最新的软件包。(即相当于把“软件列表”更新了,但是还没有把“本地的旧软件”进行升级)

  • upgrade

upgrade 是升级已安装的所有软件包,升级之后的版本就是本地索引里的,因此,在执行 upgrade 之前一定要执行 update, 这样才能是最新的。(即把“本地的旧软件”进行升级,升级为“软件列表”的版本)

如果更换了系统默认的源(中科大->阿里云),此时update更新了软件列表,又进行upgrade升级,会把系统原来的中科大下载软件全部升级成阿里云下载的软件。在使用最新软件时会报错“系统某个库版本低”,软件不能正常使用问题,所以需要谨慎操作upgrade。

posted @ 2023-02-14 10:18  程序员没有头发  阅读(544)  评论(0编辑  收藏  举报