Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

When I try to install any package through the command line, I get an error. Can anyone help me on this?

$ sudo apt-get install <package>
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package <package>
share|improve this question
unable to locate package is merged with this Question. –  Pandya Sep 11 '14 at 14:02

3 Answers 3

up vote 9 down vote accepted

First, check if the package actually exists:

  1. Go to packages.ubuntu.com with a web browser.
  2. Scroll down to "Search package directories"
  3. Enter the package which you're trying to install into the "Keyword" field.

    Enable "Only show exact matches:"

    Change the "Distribution" to which version of Ubuntu you're using.

    enter image description here

If there are no results, the package you are looking for doesn't exist and the next steps will not work. It may require a third party PPA or an alternative installation method.

If results are found, the package exists and you may continue with these steps:

  1. Open Software Sources (or Software & Updates in 13.04+) by searching for it in the Dash.
  2. Open the "Ubuntu Software" tab.
  3. Ensure that the first 4 check boxes on this tab are enabled:

    enter image description here

  4. Update the package lists, then test with these commands:

    sudo apt-get update
    sudo apt-get install <TEST_PACKAGE>
share|improve this answer

There are many questions about this topic Here provided basic/general answer.

When apt-get install unable to locate package that means the package you want to install couldn't find within repositories that you have added or exist in /etc/apt/sources.list and under /etc/apt/sources.list.d/.

The following (General) procedure helps to solve this :-

  1. Make sure enabled Ubuntu repositories:

    To enable all (main, universe, restricted, multiverse) following command is useful:

    sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu $(lsb_release -sc) main universe restricted multiverse"

    Visit Help for more information.

  2. For finding PPA for more packages:

  3. Add ppa (by command-line):

    Add ppa by following command:

    sudo add-apt-repository ppa:<repository-name>

    Visit Ubuntu community help for full information.

  4. Don't forget to update (make apt aware of your changes):

    It is very essential to run following command after changing in repositories:

    sudo apt-get update

    Selecting best download server may helps to fast update.

  5. Finally install package:

    Then install package by sudo apt-get install <package>

    Refer Package management by commandline.

    Additional: you can find correct package-name (i.e version from repository) by apt-cache search [package-name].

I tried my best by 5 step-wise help. Hope it help as answer.

Note: If package is not available on repository any how, than you have to go with other installing process than apt-get ex: compile etc.

share|improve this answer
It could also be that the user is searching for libname, when it's libname2 in Debian/Ubuntu. –  saiarcot895 Jun 10 '14 at 14:46
First, is depends on the package and you are making a number of assumptions. First, you are assuming the OP has identified the correct package name, as pointed out by saiarcot895 . Second you are assuming the packages is available. In general, it is best to first identify the problem. Then if at all possible install from the repositories. Unless there is a specific need, ppa is a second choice. If the package is not in the repositories or ppa it may need to be compiled from source. You really do not have enough information. –  bodhi.zazen Jun 10 '14 at 15:06
@saiarcot895 @bodhi.zazen : Revised answer with providing apt-cache search to find correct package-name from repositories. –  Pandya Sep 11 '14 at 13:56

In the case where tried to install a file:

sudo apt-get install libstdc++.so.6

instead of a package. You get the error message:

E: Unable to locate package libstdc++.so.6
E: Couldn't find any package by regex 'libstdc++.so.6'

because you tried to install a file libstdc++.so.6 that you can't install, because it is located in a debian package.

You can use apt-file to search for the package that contains that file. To install it, type:

sudo apt-get install apt-file

Then you have to update the index.

sudo apt-file update

After that, you can search for the package which contains the file libstdc++.so.6:

sudo apt-file find libstdc++.so.6

Then you find a lot packages that contains the searched file. For this example I paste only one search result:

libstdc++6: /usr/lib/x86_64-linux-gnu/libstdc++.so.6

Then you can install the needed package libstdc++6:

sudo apt-get install libstdc++6
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.