How to Fix ‘Unable to Locate Package’ on Ubuntu Linux

Ubuntu

Unable to locate package on Ubuntu Linux? Here’s the fix!

Linux offers its users flexibility in terms of how they manage and interact with their software. You have many options and multiple courses of action to take when working on package management. 

However, you might have encountered an issue common to many Linux systems “Unable to locate package” several times. This issue has popped up on several Linux distros like Ubuntu, Debian, Fedora, Kali Linux, and a few others.

If you’re unable to locate package on Ubuntu Linux, don’t worry, as today we will dive into the cause of this issue and try to counteract it with a fix.

We will go about several approaches so you can use the one that fits you best. So without any further ado, let’s jump straight into the process of this error extermination.

Installing Appropriate Repositories.

Occasionally, when we are installing a package using the terminal, we encounter an error that states the package cannot be installed. This issue is faced more frequently by the users of the 18.04 version.

locate package on Ubuntu

This error arises because the apt-get install cannot find the desired package in the repositories we have added. They are loaded in /etc/apt/sources.list. It could also mean the desired files we are looking for may be corrupted.

In that case, we enable all repositories. There are 4 main repositories:

Main: It is the officially supported version by Canonical, which is Ubuntu’s parent company. It is open source.

Restricted: It is the closed source counterpart of the main version. It is also supported by Canonical.

Universe: It is the community-supported software that is closed source. The Linux community maintains its affairs like updates, security patches, etc.

Multiverse: This is the closed source. It is not supported, which means Ubuntu can’t distribute these packages, at least officially. But they are there for one’s own convenience.

There is a good chance that the package you are looking to install is in one of these 4 repositories. So enabling all of them makes the chance of a successful installation highly likely. Especially considering the case that they are usually disabled by default in Ubuntu 18.04. 

Type the following commands in the terminal:

$ sudo add-apt repository main
$ sudo add-apt repository restricted
$ sudo add-apt repository universe
$ sudo add-apt repository multiverse
locate package on Ubuntu

In our case, it is already enabled. In Ubuntu 20.04, these repositories are enabled by default, which means our issue is still not resolved.

In that case, we go to the specific directory for the package we want to install.

For that, we first visit Ubuntu – Ubuntu Packages Search

Here we search for the package and version we require.

locate package on Ubuntu

As we are using the long-term version 20.04, we click it and look for the desired java package in the subsection to install.

desired java package in the subsection to install.

In the “Java” section lie several repositories out of which we can install the ones we need.

Alternatively, you can search directly for the repositories using the search options in the window below to narrow your results and save more time.

search for the repositories
locate package on Ubuntu
locate package on Ubuntu

This should resolve your issue. However, if you can still locate the package on Ubuntu Linux, we have other procedures you can follow and precautions you can take so you stay on the safe side.

Although they may seem trivial, there can be several minor issues that can make all the difference. For instance, a few mentioned below:

Case 1: Incorrect Package Name.

You may not be able to install your desired package due to a typing error. It should also be noted that the package names are case-sensitive. So one needs to look out for that. For example, “Nmap” is not the same as “nmap”.

Case 2: Updating and Upgrading Packages.

In many cases where your package may not be downloaded, the underlying cause could be an outdated system. We start by updating our cache. You can achieve this by typing the following command in the terminal.

$ sudo apt update
locate package on Ubuntu
locate package on Ubuntu

Now we upgrade to install the packages.

Upgrading might download the necessary packages you needed to complete the final piece of the puzzle. For this purpose, type the following command in the terminal.

$ sudo apt get-upgrade
locate package on Ubuntu

If you’re still unable to locate the package on Ubuntu Linux, you can troubleshoot for the third case.

Case 3: Check Your OS Version.

Sometimes, we may face an issue regarding the download even when we are following all tutorial steps. This probably happens because our current version is incompatible with the package under discussion, so it is good to check your version and see if the package for that version is released and compatible.

You can check the version by typing:

$ lsb_release-a

If the Ubuntu version you are using is no longer supported. There’s a good chance you won’t be able to find the package. The straightforward solution is to upgrade to the latest version.

Steps to Update Your System OS.

We will go through a brief overview that explains how you can download the package in a well-defined sequence:

  1. First and foremost, update your system. This is the preliminary step that is recommended before installing anything. If an upgrade is required to download additional files, do that as well.
  2. If the package still doesn’t download, try enabling all the repositories. This enables multiple sources for packages to be obtained from and consequently increases the probability of your success.
  3. If the error subsists, go to the next step of manual package search at packages.ubuntu.com and look up the search package directories. Be careful in the distribution panel. Make sure you download the package for the distribution you are currently using.
  4. You should also try changing the server from the “software and updates section”. It has worked for several people, so it is worth the shot.
selecting best servers
  1. Finally, if nothing has worked for you, it probably means the version you use does not support the package you are using. In that case, it is recommended you update your OS version (An LTS version is recommended as it will be supported officially for at least 2 years).

Hopefully, this article helped those who were unable to locate package on Ubuntu Linux. Now you should be able to download and install whatever it is you need.

If you wish to see how to free up space/boot partition check out this article that explains how to free space/boot partition on Ubuntu, click here.

If this guide helped you, please share it. 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *

Previous Post

How to Run Java from Command Line in Linux

Next Post

How to Enable ZFS Compression on Linux

Related Posts