Installing packages on a Linux system, including Kali Linux, is a common and widely used task. The reason is, most packages are available in the official system repository and can be installed through the apt install command. However, sometimes you may encounter unable to locate package error on your system that prevents you from installing the application through apt repository. There are a number of reasons for the occurrence of unable to locate package error on Kali Linux.
In this guide, you will learn:
- Why Unable to Locate Package Error Occurs on Kali Linux
- How to Fix Unable to Locate Package Error on Kali Linux
- Bonus Method: How to Fix “sudo: add-apt-repository command not found” on Kali Linux
While installing a package on your Kali Linux system, you may encounter unable to locate package error, as shown below:
The unable to locate package error occurs in a system because the package you want to install is not available in the source repository. This might be due to the repository you added doesn’t include the package you want to install. Though, most of the packages are available in the Kali Linux official repository, so this error might occur due to some issue in the official system repository.
To fix unable to locate package error on Kali Linux, you can use the following steps:
Step 1: Create a Backup File on Kali Linux
First, it is recommended to create a backup of your sources.list file where all repositories are saved. Doing this will ensure recovering your file in case you have edited the file in a wrong way. You can create a backup of sources.list file on Kali Linux by using the following command:
Step 2: Remove Everything from sources.list File
Now, open the repository source file sources.list on Kali Linux and removes everything inside the file using CTRL+K. You can open the Kali Linux repository file by using the nano editor from the below-given command:
Step 3: Add Repository to Kali Linux
Now, head towards the Kali Linux network repositories web page and add the kali-rolling repository to sources.list file starting from deb:
Once the repository is added, you can save the file using CTRL+X, then add Y to approve the changes in the file and pressing the Enter button to close the file.
Alternatively, the following command can also be used to add the repository to Kali Linux system:
Step 4: Update Kali Linux Repository
Once you added the repository, update your Kali Linux system using the below-given command to ensure the changes are successfully applied:
Step 5: Install the Package on Kali Linux
After updating the repository without any warning or error, you can reinstall that application from the apt install command. Here, I have installed VLC media player from the official Kali Linux repository, which was causing error in the previous run:
Note: If you are still encountering unable to locate package error on Kali Linux, then you should add the package repository to the system. The reason is that the package won’t be there in the system repositories currently added to your system. You can find the repository with a GPG key to install a specific package on the official website of that package. Just add a repository and GPG key, then update the repository and install that application through the apt install command with the package name.
Sometimes, the repositories for installing a package are added to the Kali Linux system with the add-apt-repository command. However, this command will not work by default on some Linux systems, including Kali Linux because of dependencies conflict or compatibility issues. When you try to add a repository to Kali Linux with the add-apt-repository command, you will get the following error:
You can fix this error on Kali Linux and other Linux distribution by installing the following dependencies on Kali Linux:
After that, you can use the add-apt-repository command to add any repository, install packages from that repository and fix unable to locate package error on Kali Linux.
As an example, I have added the following repository to Kali Linux system for installing ffmpeg:
Note: You may find ffmpeg in the official Kali Linux repository, however, the example provided is just to guide you how you can fix the add-apt-repository command not found error.
By default, apt-apt-repository updates the repository list, however, to ensure the repository is updated, you may run the below-given command:
Then install the application using the apt install command on Kali Linux system:
Note: If you are still encountering unable to locate package error on Kali Linux, then you can install and use independent package managers like Flatpak and Snap. These package managers include several packages that you may not find in the official Kali Linux repository. Most likely, you will find and install your required packages with these package managers on your Kali Linux system.
Further, some packages also have a deb file that you can download on your system and install the package from the apt install command using the following syntax:
Unable to locate package is a common error in Linux systems including Kali Linux that occurs if there is a problem in the repository or the package is not available. You can fix the error related to your package by removing the repository and adding one again if there is an issue with the repository. If the package is not available, you can also add another repository using the same step-by-step guidelines for adding the repository in the above-section of this guide. Further, you can also fix the add-apt-repository command not found error by installing dependencies on your system. Once done, you can utilize the add-apt-repository command to add an external repository and install the package to fix the error.
By day, I am an engineer and researcher, building bridges and figuring out how the universe works. But when the clock strikes five, I turn into a wordsmith!
I write about my adventures on my blog, sharing tips and tricks to help others join the tech fun. I have worked on Raspberry Pi, Ubuntu, Debian, and Laptops. Right now, I have accepted the challenge of working on the Kali Linux system, and with my vast expertise in Linux systems, I will help users overcome the challenges through my blogs.