apt-get gives error: Unable to locate package <package name> for all packages

22,031

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.

Share:
22,031

Related videos on Youtube

QxQ
Author by

QxQ

Updated on September 18, 2022

Comments

  • QxQ
    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
      MariusMatutiae over 10 years
      Did 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
      QxQ over 10 years
      that 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 says duplicate sources.list entry everywhere, but running that with cowsay acts like it did previously.
    • Lawrence
      Lawrence over 10 years
      Can you paste the contents of /etc/apt/sources.list somewhere ?
    • QxQ
      QxQ over 10 years
      I pasted it here
  • QxQ
    QxQ over 10 years
    that didn't seem to do anything.
  • Blaizz
    Blaizz over 10 years
    I updated the answer, I forgot to tell you to run sudo apt-get update after you finish editing the sources.list file.
  • QxQ
    QxQ over 10 years
    thanks for the help, but it still not working. is it possible to reinstall apt-get? maybe its just corrupt or something.
  • Blaizz
    Blaizz over 10 years
    Before 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
    Blaizz over 10 years
    @QxQ I have followed your suggestion. :)