![如何修复 apt-get 更新和安装错误?](https://linux22.com/image/850325/%E5%A6%82%E4%BD%95%E4%BF%AE%E5%A4%8D%20apt-get%20%E6%9B%B4%E6%96%B0%E5%92%8C%E5%AE%89%E8%A3%85%E9%94%99%E8%AF%AF%EF%BC%9F.png)
之前我曾使用过:
sudo apt-get remove samba
我以为它会删除 samba。但它开始卸载我的所有应用程序,包括 libreoffice、texteditor、java 插件软件更新管理器等。
现在我收到更新命令的错误
$ sudo apt-get update
Err http://snapshot.debian.org lenny Release.gpg
Something wicked happened resolving 'snapshot.debian.org:http' (-5 - No address associated with hostname)
Err http://archive.ubuntu.com precise Release.gpg
Something wicked happened resolving 'archive.ubuntu.com:http' (-5 - No address associated with hostname)
Err http://snapshot.debian.org lenny/updates Release.gpg
Something wicked happened resolving 'snapshot.debian.org:http' (-5 - No address associated with hostname)
Ign http://archive.ubuntu.com precise Release
Ign http://snapshot.debian.org lenny Release
Ign http://snapshot.debian.org lenny/updates Release
Ign http://snapshot.debian.org lenny/main TranslationIndex
Ign http://snapshot.debian.org lenny/updates/main TranslationIndex
Ign http://archive.ubuntu.com precise/main TranslationIndex
Ign http://archive.ubuntu.com precise/multiverse TranslationIndex
Ign http://archive.ubuntu.com precise/restricted TranslationIndex
Ign http://archive.ubuntu.com precise/universe TranslationIndex
Err http://snapshot.debian.org lenny/main Sources
Something wicked happened resolving 'snapshot.debian.org:http' (-5 - No address associated with hostname)
Err http://snapshot.debian.org lenny/main i386 Packages
Something wicked happened resolving 'snapshot.debian.org:http' (-5 - No address associated with hostname)
Err http://snapshot.debian.org lenny/updates/main Sources
Something wicked happened resolving 'snapshot.debian.org:http' (-5 - No address associated with hostname)
Err http://snapshot.debian.org lenny/updates/main i386 Packages
Something wicked happened resolving 'snapshot.debian.org:http' (-5 - No address associated with hostname)
Err http://snapshot.debian.org lenny/main Translation-en_US
Something wicked happened resolving 'snapshot.debian.org:http' (-5 - No address associated with hostname)
Err http://snapshot.debian.org lenny/main Translation-en
Something wicked happened resolving 'snapshot.debian.org:http' (-5 - No address associated with hostname)
Err http://snapshot.debian.org lenny/updates/main Translation-en_US
Something wicked happened resolving 'snapshot.debian.org:http' (-5 - No address associated with hostname)
Err http://snapshot.debian.org lenny/updates/main Translation-en
Something wicked happened resolving 'snapshot.debian.org:http' (-5 - No address associated with hostname)
Err http://archive.ubuntu.com precise/main Sources
Something wicked happened resolving 'archive.ubuntu.com:http' (-5 - No address associated with hostname)
Err http://archive.ubuntu.com precise/universe Sources
Something wicked happened resolving 'archive.ubuntu.com:http' (-5 - No address associated with hostname)
Err http://archive.ubuntu.com precise/restricted Sources
Something wicked happened resolving 'archive.ubuntu.com:http' (-5 - No address associated with hostname)
Err http://archive.ubuntu.com precise/multiverse Sources
Something wicked happened resolving 'archive.ubuntu.com:http' (-5 - No address associated with hostname)
Err http://archive.ubuntu.com precise/main i386 Packages
Something wicked happened resolving 'archive.ubuntu.com:http' (-5 - No address associated with hostname)
Err http://archive.ubuntu.com precise/universe i386 Packages
Something wicked happened resolving 'archive.ubuntu.com:http' (-5 - No address associated with hostname)
Err http://archive.ubuntu.com precise/restricted i386 Packages
Something wicked happened resolving 'archive.ubuntu.com:http' (-5 - No address associated with hostname)
Err http://archive.ubuntu.com precise/multiverse i386 Packages
Something wicked happened resolving 'archive.ubuntu.com:http' (-5 - No address associated with hostname)
Err http://archive.ubuntu.com precise/main Translation-en_US
Something wicked happened resolving 'archive.ubuntu.com:http' (-5 - No address associated with hostname)
Err http://archive.ubuntu.com precise/main Translation-en
Something wicked happened resolving 'archive.ubuntu.com:http' (-5 - No address associated with hostname)
Err http://archive.ubuntu.com precise/multiverse Translation-en_US
Something wicked happened resolving 'archive.ubuntu.com:http' (-5 - No address associated with hostname)
Err http://archive.ubuntu.com precise/multiverse Translation-en
Something wicked happened resolving 'archive.ubuntu.com:http' (-5 - No address associated with hostname)
Err http://archive.ubuntu.com precise/restricted Translation-en_US
Something wicked happened resolving 'archive.ubuntu.com:http' (-5 - No address associated with hostname)
Err http://archive.ubuntu.com precise/restricted Translation-en
Something wicked happened resolving 'archive.ubuntu.com:http' (-5 - No address associated with hostname)
Err http://archive.ubuntu.com precise/universe Translation-en_US
Something wicked happened resolving 'archive.ubuntu.com:http' (-5 - No address associated with hostname)
Err http://archive.ubuntu.com precise/universe Translation-en
Something wicked happened resolving 'archive.ubuntu.com:http' (-5 - No address associated with hostname)
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/precise/Release.gpg Something wicked happened resolving 'archive.ubuntu.com:http' (-5 - No address associated with hostname)
W: Failed to fetch http://snapshot.debian.org/archive/debian/20070730T000000Z/dists/lenny/Release.gpg Something wicked happened resolving 'snapshot.debian.org:http' (-5 - No address associated with hostname)
W: Failed to fetch http://snapshot.debian.org/archive/debian-security/20070730T000000Z/dists/lenny/updates/Release.gpg Something wicked happened resolving 'snapshot.debian.org:http' (-5 - No address associated with hostname)
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/precise/main/source/Sources Something wicked happened resolving 'archive.ubuntu.com:http' (-5 - No address associated with hostname)
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/precise/universe/source/Sources Something wicked happened resolving 'archive.ubuntu.com:http' (-5 - No address associated with hostname)
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/precise/restricted/source/Sources Something wicked happened resolving 'archive.ubuntu.com:http' (-5 - No address associated with hostname)
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/precise/multiverse/source/Sources Something wicked happened resolving 'archive.ubuntu.com:http' (-5 - No address associated with hostname)
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/precise/main/binary-i386/Packages Something wicked happened resolving 'archive.ubuntu.com:http' (-5 - No address associated with hostname)
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/precise/universe/binary-i386/Packages Something wicked happened resolving 'archive.ubuntu.com:http' (-5 - No address associated with hostname)
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/precise/restricted/binary-i386/Packages Something wicked happened resolving 'archive.ubuntu.com:http' (-5 - No address associated with hostname)
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/precise/multiverse/binary-i386/Packages Something wicked happened resolving 'archive.ubuntu.com:http' (-5 - No address associated with hostname)
W: Failed to fetch http://snapshot.debian.org/archive/debian/20070730T000000Z/dists/lenny/main/source/Sources Something wicked happened resolving 'snapshot.debian.org:http' (-5 - No address associated with hostname)
W: Failed to fetch http://snapshot.debian.org/archive/debian/20070730T000000Z/dists/lenny/main/binary-i386/Packages Something wicked happened resolving 'snapshot.debian.org:http' (-5 - No address associated with hostname)
W: Failed to fetch http://snapshot.debian.org/archive/debian-security/20070730T000000Z/dists/lenny/updates/main/source/Sources Something wicked happened resolving 'snapshot.debian.org:http' (-5 - No address associated with hostname)
W: Failed to fetch http://snapshot.debian.org/archive/debian-security/20070730T000000Z/dists/lenny/updates/main/binary-i386/Packages Something wicked happened resolving 'snapshot.debian.org:http' (-5 - No address associated with hostname)
W: Failed to fetch http://snapshot.debian.org/archive/debian/20070730T000000Z/dists/lenny/main/i18n/Translation-en_US Something wicked happened resolving 'snapshot.debian.org:http' (-5 - No address associated with hostname)
W: Failed to fetch http://snapshot.debian.org/archive/debian/20070730T000000Z/dists/lenny/main/i18n/Translation-en Something wicked happened resolving 'snapshot.debian.org:http' (-5 - No address associated with hostname)
W: Failed to fetch http://snapshot.debian.org/archive/debian-security/20070730T000000Z/dists/lenny/updates/main/i18n/Translation-en_US Something wicked happened resolving 'snapshot.debian.org:http' (-5 - No address associated with hostname)
W: Failed to fetch http://snapshot.debian.org/archive/debian-security/20070730T000000Z/dists/lenny/updates/main/i18n/Translation-en Something wicked happened resolving 'snapshot.debian.org:http' (-5 - No address associated with hostname)
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/precise/main/i18n/Translation-en_US Something wicked happened resolving 'archive.ubuntu.com:http' (-5 - No address associated with hostname)
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/precise/main/i18n/Translation-en Something wicked happened resolving 'archive.ubuntu.com:http' (-5 - No address associated with hostname)
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/precise/multiverse/i18n/Translation-en_US Something wicked happened resolving 'archive.ubuntu.com:http' (-5 - No address associated with hostname)
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/precise/multiverse/i18n/Translation-en Something wicked happened resolving 'archive.ubuntu.com:http' (-5 - No address associated with hostname)
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/precise/restricted/i18n/Translation-en_US Something wicked happened resolving 'archive.ubuntu.com:http' (-5 - No address associated with hostname)
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/precise/restricted/i18n/Translation-en Something wicked happened resolving 'archive.ubuntu.com:http' (-5 - No address associated with hostname)
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/precise/universe/i18n/Translation-en_US Something wicked happened resolving 'archive.ubuntu.com:http' (-5 - No address associated with hostname)
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/precise/universe/i18n/Translation-en Something wicked happened resolving 'archive.ubuntu.com:http' (-5 - No address associated with hostname)
E: Some index files failed to download. They have been ignored, or old ones used instead.
此外,在尝试安装任何应用程序时,我收到错误,在本例中是安装 vim:-
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package vim-gnome is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package 'vim-gnome' has no installation candidate
任何帮助都值得感激。谢谢
答案1
-5 - No address associated with hostname
发生此错误主要是因为/etc/apt/sources.list
文件中的主机名无效或拼写错误。因此,请尝试以下命令,
sudo rm /etc/apt/sources.list
sudo cp /etc/apt/sources.list.save /etc/apt/sources.list
sudo apt-get update
笔记:在运行上述命令之前,请检查/etc/apt/sources.list.save
文件。如果文件不存在,则运行,
sudo mv /etc/apt/sources.list /etc/apt/sources.list.bak
sudo touch /etc/apt/sources.list
sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu $(lsb_release -sc) main universe restricted multiverse"
并在软件和更新中启用其他软件存储库。最后运行,
sudo apt-get update
vim-gnome
通过运行安装包,
sudo apt-get install vim-gnome