Debian 下执行apt-get命令,常见报错解决方案

debian-error-fix

大皮比较喜欢Debian,一般情况下一台VPS到手之后,往往会第一时间换成Debian系统。不过,因为不同的厂商的Debian版本不同,所以往往也会遇到一些问题。下面,就是一些常见的问题集锦,希望以后能快速查询。

1.update时,Failed to fetch

出现错误代码

W: Failed to fetch http://mirrors.163.com/debian-security/dists/squeeze/updates/ contrib/binary-i386/Packages.gz 404 Not Found
W: Failed to fetch http://mirrors.163.com/debian-security/dists/squeeze/updates/ non-free/binary-i386/Packages.gz 404 Not Found
E: Some index files failed to download, they have been ignored, or old ones used instead.

出现这个问题,一般是因为加入了natty-backports源,删除相关代码即可

sed -i ‘/natty-backports/d’ /etc/apt/sources.list{,.d/*}

2.update时,There is no public key available

出现错误代码

W: There is no public key available for the following key IDs:7638D0442B90D010
W: There is no public key available for the following key IDs:9D6D8F6BC857C906

这种情况,一般是没有信任,执行如下命令即可

apt-key adv –recv-keys –keyserver keyserver.ubuntu.com 7638D0442B90D010
apt-key adv –recv-keys –keyserver keyserver.ubuntu.com 9D6D8F6BC857C906

 

3.install 时,遇到Broken packages

这种情况比较简单,先同步源,再升级。执行命令:

apt-get update
apt-get upgrade

附:Debian更换阿里云源

先执行命令

vi /etc/apt/sources.list

删除原有代码,换成如下源内容

deb http://mirrors.aliyun.com/debian wheezy main contrib non-free
deb-src http://mirrors.aliyun.com/debian wheezy main contrib non-free
deb http://mirrors.aliyun.com/debian wheezy-updates main contrib non-free
deb-src http://mirrors.aliyun.com/debian wheezy-updates main contrib non-free
deb http://mirrors.aliyun.com/debian-security wheezy/updates main contrib non-free
deb-src http://mirrors.aliyun.com/debian-security wheezy/updates main contrib non-free

保存之后,我们再执行命令,更新源即可

apt-get update -y

No Comments

Leave a Reply

Your email address will not be published. Required fields are marked *