当我想在我的 Ubuntu 上安装任何程序时,都会出现一个错误,说我必须将其添加到我的存储库,我从 launchpad.net 找到它的 PPA,然后在终端中输入它。它说正在导入文件,然后过了一会儿说:文件已导入。当然,我现在必须更新我的存储库,但我做不到。昨天当我尝试更新它时,显示一些错误,说某些索引文件下载失败或未找到 404。我遇到了一些麻烦,试图修复它,但没有成功。我在终端上写了一些代码(我是新手),我想我把情况弄得更糟了,因为现在当我在终端中写入 sudo apt-get update 时,它会显示一条不同的消息,它在这里:E:找不到方法驱动程序 /usr/lib/apt/methods/htt。在此之前,我的意思是昨天,我花了一整天时间试图修复它,并阅读了几乎每个关于这个问题的答案,但这没有帮助。我尝试更改“Ubuntu 软件和更新”,但最后当我想保存所做的更改时,通过按“重新加载”,会显示一条消息说“无法下载存储库信息,请检查您的 Internet 连接,当时我确定我已连接到 WiFi 网络。我还尝试将主服务器更改为本地服务器,但最后保存时出现了同样的问题。简而言之,我刚刚安装了这个 Windows,我不知道该怎么办,我甚至不能用它播放音乐,也不能下载或安装任何应用程序,我真的需要你的帮助。谢谢。
这是我的终端的副本:
arash@arash-X450CC:~$ sudo apt-get update
E: The method driver /usr/lib/apt/methods/htt could not be found.
arash@arash-X450CC:~$ sudo apt-get install chrome
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package chrome
arash@arash-X450CC:~$ ^C
arash@arash-X450CC:~$ ^C
arash@arash-X450CC:~$ sudo apt-get update
[sudo] password for arash:
E: The method driver /usr/lib/apt/methods/htt could not be found.
arash@arash-X450CC:~$ sudo apt-get update
E: The method driver /usr/lib/apt/methods/htt could not be found.
arash@arash-X450CC:~$ sudo apt-get upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
arash@arash-X450CC:~$ sudo apt-get update
E: The method driver /usr/lib/apt/methods/htt could not be found.
arash@arash-X450CC:~$ apt-get upgrade
E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)
E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?
我把最后一部分重新做一遍。升级、更新、升级。结果如下:
arash@arash-X450CC:~$ sudo apt-get upgrade
[sudo] password for arash:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
arash@arash-X450CC:~$ sudo apt-get update
E: The method driver /usr/lib/apt/methods/htt could not be found.
arash@arash-X450CC:~$ sudo apt-get upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
例如我想安装 vlc 播放器,输出如下:
arash@arash-X450CC:~$ sudo apt-get install vlc
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package vlc
我做了第一部分(在进入软件和更新之前在终端中写入两个命令),这里是输出:
arash@arash-X450CC:~$ cd /etc
arash@arash-X450CC:/etc$ sudo tar cjvf apt-back.tar.bz2
[sudo] password for arash:
tar: Cowardly refusing to create an empty archive
Try 'tar --help' or 'tar --usage' for more information.
arash@arash-X450CC:/etc$
Then I went to software and updates, made sure those four parts you said are ticked in the checkboxes next to them, then went to the other tab, I mean other software, unticked all of them and pressed reload to save changes. But after a while there came an error. Here's the detailed error message:
W:Failed to fetch http://archive.ubuntu.com/ubuntu/dists/utopic/universe/binary-amd64/Packages 404 Not Found [IP: 91.189.88.149 80]
, E:Some index files failed to download. They have been ignored, or old ones used instead.
这是按照你所说的操作后的输出
chmod +x myscript.sh
./myscript.sh
#!/bin/bash
mkdir ~/apt.back
cd ~/apt.back
sudo mv --backup=numbered /etc/apt/sources.list ../apt.back/
sudo mv --backup=numbered /etc/apt/sources.list.d/*list ../apt.back/
sudo apt-get update
答案1
您的存储库已损坏。您可以通过将其恢复为发行版默认值来修复此问题。以下步骤将展示如何执行此操作。它还将包括备份您所做的更改,以便一旦它正常工作,您就可以系统地恢复您的自定义更改并确定哪些更改会破坏您的系统。
备份当前配置
$ cd /etc
$ sudo tar cjvf apt-back.tar.bz2 ./apt
现在打开软件和更新
(转至)System Settings
->(单击)Software and Updates
(单击选项卡)Ubuntu Software
->(勾选前 4 项)->(单击选项卡)Other Software
->(删除所有勾选标记)
关闭软件中心。
使用以下方式安装 VLC
$ sudo apt-get update
$ sudo apt-get install vlc
恢复您的其他自定义 PPA:
现在,对于Other Software
您自定义添加的项目,您可以通过勾选所需的项目来一次将它们恢复。如果某个项目破坏了系统,则将其删除并单独处理。
其中一些可能显然是好的,例如Googe Chrome
。
创建并运行此脚本清理您的 apt 文件夹。它将备份您的文件,以便您在它工作后可以恢复它们。
您可以通过运行以下命令来创建脚本:
$ nano myscript.sh
然后将下面的代码复制并粘贴到编辑器中。保存脚本。然后运行它以使其可执行。
$ chmod +x myscript.sh
通过以下方式运行脚本:
$ ./myscript.sh
脚本的代码:
#!/bin/bash
mkdir ~/apt.back
cd ~/apt.back
sudo mv --backup=numbered /etc/apt/sources.list ../apt.back/
sudo mv --backup=numbered /etc/apt/sources.list.d/*list ../apt.back/
sudo apt-get update
运行脚本后,您的存储库将为空。现在运行软件更新并勾选Ubuntu Software
选项卡中的前 4 项。
然后安装vlc
:
$ sudo apt-get update
$ sudo apt-get install vlc