How to Perform Wildcard Package Searches in apt-get Like yum list *xxx*


3 views

Coming from yum where yum list *xxx* works seamlessly, you'll notice apt-get doesn't support wildcards directly in package searches. This difference often frustrates developers transitioning between package managers.

The equivalent functionality in Debian/Ubuntu systems requires using apt-cache with grep:

apt-cache search . | grep "xxx"

This searches all available packages and filters results containing your pattern. The dot (.) represents all packages.

Search for Python-related packages:

apt-cache search . | grep -i python | head -n 10

Find packages containing "dev" in their name:

apt-cache search . | grep -i dev | sort

To discover which package provides a specific command:

dpkg -S $(which command_name)

For example, to find what package provides nginx:

dpkg -S $(which nginx)

Alternatively, use:

apt-file search bin/command_name

Note: You may need to install apt-file first with sudo apt install apt-file and run sudo apt-file update.

Combine with regular expressions for more powerful searches:

apt-cache search . | grep -E "python3.*dev"

Search package names only (faster but less comprehensive):

apt-cache pkgnames | grep "xxx"

For large systems, these searches can be slow. Consider:

  • Using --names-only with apt-cache to search only package names
  • Creating a local cache file for repeated searches

Example cache approach:

apt-cache search . > ~/package_cache.txt
grep "pattern" ~/package_cache.txt


Unlike yum's simple wildcard syntax (yum list *xxx*), apt-get requires different approaches for package discovery. The Debian package management system offers more precise but less intuitive search mechanisms.


For wildcard searches, use apt-cache with grep:

apt-cache search . | grep "search_term"

Example searching for Python packages:
apt-cache search . | grep -i python3 | sort

For more focused searches:
apt-cache search --names-only ".*ssl.*"


To identify which package provides a specific command:

apt-file search /bin/command_name

First install apt-file if needed:
sudo apt-get install apt-file
sudo apt-file update

Example finding which package provides 'pip':
apt-file search /usr/bin/pip

Alternative method using dpkg:
dpkg -S $(which command_name)


Combine tools for powerful queries:

apt-cache pkgnames | grep -i "dev" | xargs -n1 apt-cache show

For regex pattern matching:
apt-cache search --names-only '' | grep -E 'python3.*dev'


Finding all Java-related packages:
apt-cache search java | grep -i jdk

Identifying the package for nginx binary:
apt-file search /usr/sbin/nginx

Listing all installed packages matching a pattern:
dpkg -l | grep libssl