apt-get gives error: Unable to locate package <package name> for all packages
Your sources.list file has two duplicate software sources in it, and there may be other things wrong with it as well.
You can regenerate your whole sources.list file from scratch and rename your old sources.list file as a backup. Visit the repogen Ubuntu Sources List Generator website, and you can regenerate your sources.list file there.
A standard sources.list file for Ubuntu 16.04 looks like this:
deb http://archive.ubuntu.com/ubuntu/ xenial main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ xenial-updates main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ xenial-backports main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu xenial-security main restricted universe multiverse
deb http://archive.canonical.com/ubuntu xenial partner
A standard sources.list file for Ubuntu 18.04 looks like this:
deb http://archive.ubuntu.com/ubuntu/ bionic main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ bionic-backports main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu bionic-security main restricted universe multiverse
deb http://archive.canonical.com/ubuntu bionic partner
After you do that, tell your system to pull down the latest list of software from each archive it knows about by running the following command in the terminal:
sudo apt-get update
The repogen website has a dropdown menu that lets you select from all currently supported Ubuntu releases. It is also possible to regenerate the default sources.list file manually without visiting the repogen website by following the instructions in this answer.
Related videos on Youtube
QxQ
Updated on September 18, 2022Comments
-
QxQ almost 2 years
I have a fresh install of Ubuntu Server 13.10, and I'm trying to install an FTP server, but apt-get doesn't seem to want to install anything.
sudo apt-get install vsftpd
brings the error:unable to locate package vsftpd
.So I tried it again, but with installing the program "cowsay" instead. The same thing happens.
I did try
apt-get update
.I tried
sudo apt-cache search vsftpd
, and nothing returned. however, if I type the same command on my normal Ubuntu machine (not the server), then results do pop up.So what's wrong?
-
MariusMatutiae over 10 yearsDid you install all repos? As sudo, edit the file /etc/apt/sources.list and uncomment all lines beginning with deb. Save, run apt-get update
-
QxQ over 10 yearsthat didn't work. after running apt-get update, this error popped up:
Some index files failed to download. They have been ignored, or old ones used instead.
, and after running apt-get install vsftpd again it saysduplicate sources.list entry
everywhere, but running that with cowsay acts like it did previously. -
Lawrence over 10 yearsCan you paste the contents of
/etc/apt/sources.list
somewhere ? -
QxQ over 10 yearsI pasted it here
-
-
QxQ over 10 yearsthat didn't seem to do anything.
-
Blaizz over 10 yearsI updated the answer, I forgot to tell you to run
sudo apt-get update
after you finish editing the sources.list file. -
QxQ over 10 yearsthanks for the help, but it still not working. is it possible to reinstall apt-get? maybe its just corrupt or something.
-
Blaizz over 10 yearsBefore you do that I've got another idea. You can regenerate your whole sources.list file from scratch and rename your old sources.list file as a backup. Visit the repogen Ubuntu Sources List Generator. Don't forget to run
sudo apt-get update
to update your list of software after you replace your sources.list file. -
Blaizz over 10 years@QxQ I have followed your suggestion. :)