Home Package management How To Check Package Availability In Debian and Ubuntu Repositories

How To Check Package Availability In Debian and Ubuntu Repositories

Verify if a Package is Available in Debian or Ubuntu Repositories.

By sk
1K views

The other day, one of our blog visitors left a comment on a blog post, noting that 'libpam-cracklib' was no longer available in Debian 12, and instead, 'libpam-pwquality' had taken its place.

I wanted to make sure, so I decided to verify its availability by visiting packages.debian.org link. As expected, it was confirmed that 'libpam-cracklib' didn't exist in the official repositories for Debian version 12.

To help other users facing a similar situation, I have written this blog post to explain how to check package availability in Debian and Ubuntu operating systems, both locally and online.

At the end, I have also provided a handy Bash script to simplify this task further. Read on.

Verify Package Availability in Debian and Ubuntu Repositories from Command line

To verify if a package is available in Debian or Ubuntu repositories, you can use apt search command like below:

$ apt search libpam-cracklib

This command searches for packages in the available repositories that match the provided search term, in this case, 'libpam-cracklib.'

If you don't see any output, the given package is not available in repositories.

If the package is available in repositories, you would see an output like below.

Sorting... Done
Full Text Search... Done
libpam-cracklib/oldstable 1.4.0-9+deb11u1 amd64
  PAM module to enable cracklib support

The apt search command is useful when you want to discover if a package with a specific name is available in the repositories.

You can also use apt-cache show command to achieve the same task.

The apt-cache show command displays detailed information about a specific package that is already installed or available in the package cache (the database of package information on your system).

Let us check if libpam-cracklib package is available in locally or in the repositories using command:

$ apt-cache show libpam-cracklib
N: Unable to locate package libpam-cracklib
E: No packages found

No, the package didn't exist.

Let us check availability of the libpam-pwquality package.

$ apt-cache show libpam-pwquality
Package: libpam-pwquality
Source: libpwquality (1.4.5-1)
Version: 1.4.5-1+b1
Installed-Size: 40
Maintainer: Debian GNOME Maintainers <pkg-gnome-maintainers@lists.alioth.debian.org>
Architecture: amd64
Depends: libc6 (>= 2.4), libpam0g (>= 1.1.1), libpwquality1 (>= 1.1.0), libpam-runtime
Description-en: PAM module to check password strength
 libpwquality's purpose is to provide common functions for password
 quality checking and also scoring them based on their apparent randomness. The
 library also provides a function for generating random passwords with good
 pronounceability.
 .
 This module can be plugged into the password stack of a given service to
 provide some plug-in strength-checking for passwords. The code was originaly
 based on pam_cracklib module and the module is backwards compatible with its
 options.
Description-md5: a0adf9a37eba9a9b210c968269f49c5e
Multi-Arch: same
Homepage: https://github.com/libpwquality/libpwquality
Section: admin
Priority: optional
Filename: pool/main/libp/libpwquality/libpam-pwquality_1.4.5-1+b1_amd64.deb
Size: 12900
MD5sum: c505c02a13416c8603ca3b87c44a68dc
SHA256: 1af9459d90da346d40b030cf773c17c4fd7bd3ebe903d2bfaf494e7ec73b875c

Indeed, it is available!

As you see in the output, the apt-cache command provides extensive details about the package, including its version, description, dependencies, maintainer information, and more.

It's helpful when you want to gather specific information about a package, like its description, dependencies, or any other relevant details.

In summary, apt search is used for searching and discovering packages, while apt-cache show is used for retrieving detailed information about a specific package.

Depending on your needs, you may use one or both of these commands when working with package management in Debian and Ubuntu systems.

As evident from both outputs, there is no clear indication of whether the provided package is available for a specific version, such as Debian 12.

For instance, if you wish to verify the package availability of a specific package for Debian 12 from a Debian 11 system, you can't be certain whether the package is available for the intended version.

To obtain this information, you will need to perform a search on the official Debian or Ubuntu websites, as explained in the following section.

Examine Package Availability in Debian and Ubuntu Repositories via Official Website

To check if a package exists for a particular OS version, you'll need to consult the repositories specific to that OS version. Both Debian and Ubuntu offer online package search tools.

If you're on Debian follow the steps below:

1. Visit https://packages.debian.org/ link.

2. Scroll down a little bit and you will see "Search package directories" section. Enter your package name in the Keyword box. Select the desired release from the Distribution dropdown menu and hit the "Search" button.

Examine Package Availability in Debian Repositories via Official Website
Examine Package Availability in Debian Repositories via Official Website

Please note that the term 'stable' in the 'Distribution' dropdown box refers to Debian 12. As you already know, Debian 12 is the current stable release.

If you're on Ubuntu, then visit https://packages.ubuntu.com/ link and do the following:

1. Enter the package name in the Keyword box.

2. Choose the distribution version (E.g. focal) and click the Search button.

Check Package Availability in Ubuntu Repositories via Official Website
Check Package Availability in Ubuntu Repositories via Official Website

This method is better than the previous command-line one because it allows you to search for package availability on Debian-based systems from any Linux or Windows system, using only a web browser.

A Bash Script to Check Package Availability in Debian and Ubuntu Repositories

I have put together the aforementioned steps in a simple and handy Bash script that tells you whether a package is available for a Debian or Ubuntu version. All you have to do is just download the script, make it executable, and run it.

This script is known as dpkg-repo-query. It prompts the user for a package name and a distribution/version. It then checks the official Debian or Ubuntu repositories to see if the package is available for the given version/codename. The result is displayed in a neat table format.

The script is published in GitHub, and you can use it on any system that supports Bash.

1. Git clone the repository using command:

$ git clone https://gist.github.com/ostechnix/86362cb9361f7f5ccf7de43a33e915de dpkg-repo-query

This clones the script inside a directory named dpkg-repo-query in the current working directory.

2. Cd into the directory and make the script executable using commands:

$ cd dpkg-repo-query
$ chmod +x dpkg-repo-query.sh

3. Run the script as sudo user:

$ sudo ./dpkg-repo-query.sh

4. You will be prompted to enter the name of the package (E.g. libpam-cracklib).

Enter the package name: libpam-cracklib

5. Next type the distribution name. Type either debian or ubuntu.

Enter the distribution (debian/ubuntu): debian

6. Type the distribution version (code name or number). For example type, bookworm for Debian 12, and jammy for Ubuntu 22.04 LTS.

Enter the distribution version (e.g., buster, jammy, 22.04, 11, etc.): bookworm

You can also enter the version numbers instead of code names. For example, type 12 for Debian 12 and 22.04 for Ubuntu 22.04 LTS versions. Of course, you can change this behavior by editing the script.

7. That's it. The script will now display the availability of the given package for the chosen distribution in a nice tabular column.

+----------------+----------------+----------------+----------------+
| Package Name   | Distribution   | Version        | Status         |
+----------------+----------------+----------------+----------------+
| libpam-cracklib | debian         | bookworm       | Not Available  |
+----------------+----------------+----------------+----------------+
Bash Script to Check Package Availability in Debian and Ubuntu Repositories
Bash Script to Check Package Availability in Debian and Ubuntu Repositories

You can check the script in our official GitHub repository given below.

Feel free to adapt and improve this script as per your requirements. Any improvements to this script are much appreciated.

Conclusion

In this tutorial, we discussed how to check if a package is available in Debian or Ubuntu repositories from both command line and online.

We also provide a simply Bash script to check a package availability for Debian-based systems. Hope this was useful.

Related Read:

You May Also Like

Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

This website uses cookies to improve your experience. By using this site, we will assume that you're OK with it. Accept Read More