How can I update my repository?
Your repository is corrupted. You can fix this by bringing it back to the distribution defaults. The steps below will show how to do this. It will also include backing up the changes you've made so that once it's working you can systematically bring back your custom changes and identify which one(s) is breaking your system.
Make a backup of your current configuration
$ cd /etc
$ sudo tar cjvf apt-back.tar.bz2 ./apt
Now open the Software and Updates
(go to) System Settings
-> (click) Software and Updates
(click the tab) Ubuntu Software
-> (check mark the first 4 items) -> (click the tab) Other Software
-> (Remove all check marks)
Close the software center.
Install VLC with
$ sudo apt-get update
$ sudo apt-get install vlc
Restoring your other custom PPA's:
Now for the Other Software
items you have custom added, you can bring them back one at a time by placing a check mark on the desired one. If one breaks the system, then leave it out and deal with it individually.
Some of them might be obviously a good one, like Googe Chrome
.
Create and run this script to clean out your apt folder. It will backup your files so that you can restore them after it's working.
You can create the script by running:
$ nano myscript.sh
Then copy and past the code below into the editor. Save the script. Then run this to make it executable.
$ chmod +x myscript.sh
Run the script by:
$ ./myscript.sh
The code for the script:
#!/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
After running the script your repository will be empty. Now run the Software updates and checkmark the first 4 items in the Ubuntu Software
tab.
Then install vlc
with:
$ sudo apt-get update
$ sudo apt-get install vlc
Related videos on Youtube
arash
Updated on September 18, 2022Comments
-
arash over 1 year
When I want to install any program on my Ubuntu, There comes an Error saying I have to add it to My repository, I find its PPA from launchpad.net and then type it in the terminal. it says the file is being imported, then after a while says: the file imported. Naturally, I have to update my repository now, but I can't. Yesterday when I tried to update it some errors were shown saying that some index files failed to download or 404 not found. I had some troubles with it and tried to fix it but couldn't. I worked on some codes in the terminal( I am new to this), and I think I made it worse, because now when I write sudo apt-get update in The Terminal, It shows a different message, here it is : E : the method driver /usr/lib/apt/methods/htt could not be found. Prior to this, I mean yesterday, I spent the whole day trying to fix it and read almost every single answer to any question asked about this issue but it didn't help. I tried to make changes to " Ubuntu software and update" but at the end when I wanted to save the changes made, through pressing " reload" a message would be shown saying " failed to download repository information, check your Internet connection, it was while I was sure that the I was connected to a WiFi network. I also tried to change the main server to a local server but at the end when saving there was the same problem. Briefly, I have just installed this windows and I don't know what to do, I can't even play music with this, niether I can download or install any apps, I really need your help. Thank you.
This is a copy of my terminal:
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?
I did the last part over. upgrade,update,upgrade. here is the result:
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.
for example I want to install vlc player, here comes the output:
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
I did the first part( writing the two commands in the terminal-before going to software and updates), here is the output:
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.
here is the output after doing what you said
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
step 1 this pic is for the first command. I did it with another name.
step 2 the next pic. for the next step after pressing ctrl+o to save. then I pressed enter.
-
Apologician over 7 yearsYour message is hard to read because you don't have any vertical white spaces (paragraphs). It's hard to tell where one thought starts and the other stops. You might be having a dns problem as a results of not being able to connect to the repositories. Copy and paste some of the exact error messages you are getting we could deal with each of the specific errors and get the issues resolved. You're making lots of generalizations. Whereas we need specifics, such as an attempt to install a specify program and the exact error message copied and pasted to your question.
-
arash over 7 yearsokay, when I wanna update, heres the Error: E : the method driver /usr/lib/apt/methods/htt could not be found.
-
Apologician over 7 yearsMost likely you typed in
sudo apt-get update
to update. Can you copy at less the last 10 lines of code that appeared after you pressed ENTER and paste it into your question. Add it to the bottom of your question... also making a reference to the exact command you typed in. -
arash over 7 yearsWhen I press enter there comes only one line, the one i said.
-
arash over 7 yearsBut before this problem, when I tried to update, there where other issues like : 404 package not found or some index files failed to download.
-
Apologician over 7 yearsDuring the process of update some of the repository addresses do change and will give that error. But subsequent
apt upgrade
andapt update
will automatically fix the proper repository addresses. We could tell better what's happening if we could see a few lines at least 10 of the lines exactly the way it appears on your screen. -
Apologician over 7 yearsWill you perform these commands and copy and paste the output to the bottom of your question.
sudo apt-get upgrade
thensudo apt-get update
thenapt-get upgrade
. Notice there is twoupgrade
commands. One of the upgrades may fix the links then the nextupdate
will rebuild the your repository cache. -
Apologician over 7 yearsBy the way, if the problem is related to your
dns
(internet configuration) we should be able to tell by the exact output on your console. -
arash over 7 yearsI captured a picture from the terminal, you might want to take a look at it, I sent it to your email address.
-
Apologician over 7 yearsYou will have to copy and paste the output to your question so that others can participate, assist in the fix and benefit from the resolution. As far as DNS, you could probably spend a lot of time studying networking, or you can provide us with the exact errors you're getting and we could tell and advise you how to resolve your issue.
-
arash over 7 yearsI added a copy of what you said. Now what to do?\
-
Apologician over 7 yearsThe last command
apt-get upgrade
command was missing thesudo
. Can you execute it again and add the output to your question? Also, there's a change the repository that you tried to add might be broken. I'll be able to tell this by the output that you show. As far as DNS, I can't see that you are not having a problem with that. -
arash over 7 yearsI did what you said over. upgrade,update,upgrade. copied it to the question
-
Apologician over 7 yearsWhat is the name of the application that you are trying to install with this
ppa
? -
Apologician over 7 yearsAlso, what is the
ppa
link that was provided by launchpad.net? -
arash over 7 yearsI can't install any application. For example I want to install vlc player. It should be said that I can't even install applications from ubuntu software center.
-
Apologician over 7 yearsRun this:
sudo apt-get install vlc
. Please add the output of that to your question. -
Apologician over 7 yearsThanks the problem and resolution is clear. Give me a minute to provide you with easy to follow steps for the resolution.
-
Apologician over 7 yearsA few more minutes. I'm testing the resolution.
-
Apologician over 7 yearsI have provided an answer with formatted steps to resolve your issue.
-
Thomas Ward over 7 yearsComments are not for extended discussion; this conversation has been moved to chat.
-
-
arash over 7 yearsI did what you said step by step, when I did the first part(writing the commands in the terminal-before going to software and updates) The output was weird. I copied it to the question.
-
arash over 7 yearsI think it has problems with my IP, Would it be useful if I change it? If yes, how can I change it?
-
Apologician over 7 years@arash I updated the tar command. It should work now. Are you sure you unchecked all the items in the
Other Software
list? -
arash over 7 yearsyes I am sure on that. I guess that might be because of my IP, is it possible to change my IP address?
-
Apologician over 7 yearsThere's a new section in the answer. Follow the steps in
Create and run this script
. Post the output of the script. Your current files will then be backed up to anapt.back
folder in your home directory. You fix those files at a different time and move them back to your repository after the repository is working. -
Apologician over 7 years@arash Before executing the script you have to run this on the script:
chmod +x myscript.sh
. -
arash over 7 yearsI got an output. will write it in the question
-
Apologician over 7 years@arash There's something missing. Looking at what you posted I can only see the commands. There should have been something else displayed on your screen... either error messages or some update. Especially after the last command which is
sudo apt-get update
. -
arash over 7 yearswhat should I do now?
-
Apologician over 7 yearsWhat did you see on the screen after you executed this command:
./myscript.sh
? What did you see between the command and the prompt that came after you ran the command? -
web.learner over 7 yearsComments are not for extended discussion; this conversation has been moved to chat.
-
arash over 7 yearsPlease look at the question now Then after pressing enter nothing happened so I wrote the next command ./myscript.sh but nothing happened again. the I added the other command, I mean the large one and you saw the output(in the question)
-
Apologician over 7 yearsPlease use the link moved to chat, posted by Seth for update questions and comments on implementing the answer.