How to Search for a Package in Ubuntu with apt

How to Search for a Package in Ubuntu with apt

Knowing a program’s job but not its Ubuntu package name is enough to try apt search with a word describing that job. I can’t resist how a small search word can reach beyond package names into their descriptions.

To make sense of a broad match, focus on the information APT searches. You can explore the local package lists apt search reads to see what feeds the match.

What apt search reads

APT searches package metadata in the local lists for the software sources enabled on Ubuntu. Searching reads that metadata, so it doesn’t install or change a package.

The Ubuntu apt manual describes search as a regular-expression search through available package lists. The apt-cache manual says its search checks package names and descriptions, so a broad term can return unrelated packages.

CommandWhat it searchesWhen to use it
apt search TERMAvailable package metadataRead package versions and summaries in a terminal
apt-cache search TERMPackage names and descriptionsGet compact package-name and summary rows
apt-cache search –names-only TERMPackage names and provided names, excluding long descriptionsReduce matches caused by description text

A broad term can appear in a description without naming the program you want. This archived apt-cache output shows why each result needs a quick read.

Ubuntu package search results for sudo from apt-cache, showing package names and short descriptions
Archived apt-cache search sudo output. It shows names and descriptions that matched the term at the time. Repository contents change.

The package list and descriptions depend on your configured repositories. The archived screenshot shows the output shape, while your local index tells you which versions your sources offer.

What needs to be in place before searching

Your enabled repositories decide which package names can appear. APT searches their local indexes, so a repository change or an old index can leave a package out of the results.

  • Check that the source offering the software is enabled for your Ubuntu release.
  • Refresh the package lists after changing sources or when a package you expect is missing.
  • Use the package name for a repository search. A downloaded DEB file is a separate install path.

If you have a local DEB file, follow the Ubuntu DEB installation steps instead of searching the repository index for its filename.

Search by a package name or feature

If the package label isn’t familiar, a term describing what the software does gives APT another field to search. Read each summary before choosing.

apt search '^curl$'

After refreshing the package lists, I ran apt search with the anchored curl expression and saw curl marked as installed. The row showed its version and repository labels.

apt search '^curl$' output showing a package version, repository labels, architecture, installed status, and description
apt search displays the package version and installed state from your local package indexes. Repository labels and available versions depend on your enabled sources.

APT warns that its terminal display can change, so scripts should not parse it.

Narrow results to package names

The –names-only option skips long descriptions, and ^curl$ asks apt-cache to match the entire package name so a word inside a description cannot satisfy the query.

apt-cache search --names-only '^curl$'
ExpressionWhat it matches
curlNames containing curl
^curl$The exact name curl

I ran the anchored search and got one package-name row. The screenshot shows that row and its short description.

apt-cache search --names-only exact curl package query returning one result on Ubuntu 24.04
Ubuntu 24.04 arm64 cache output for an exact curl package-name search. Package rows vary by enabled repositories.

The option skips long descriptions, while provided package names can still match. The Ubuntu manual documents that boundary, so use an anchored expression when you need the literal package name.

Check a candidate before installing

Before choosing a package, check whether it is installed and which version APT would select.

CommandWhat to check
apt show curlDescription, version and dependencies for the package
apt-cache policy curlInstalled and candidate versions, with their repository sources
apt list –installed curlWhether curl is installed

I ran all three checks for curl. The installed and candidate versions matched in the refreshed local index, but another machine can show a different version or source.

If you want to check packages already on the system, see how to list installed packages with apt.

When APT returns no match

Because APT reads local package lists, a stale index can hide packages recently added to a repository. Run sudo apt update before searching again.

sudo apt update
  1. Check spelling and try a shorter name or description term.
  2. Confirm that the repository component is enabled for the Ubuntu release you run. Use the Ubuntu version check if you need its release name.
  3. If the project offers an AppImage rather than an apt package, use that separate format and follow the AppImage installation steps.

Check who maintains the source and whether it supports your Ubuntu release before adding it.

Search when you have a file path

APT package search finds names and descriptions. To identify the installed package that owns a local path, use dpkg-query -S instead.

dpkg-query -S /usr/bin/curl

The Ubuntu dpkg-query manual documents this installed-package lookup. I ran it for /usr/bin/curl, and it returned the curl package.

To search file lists for packages that are available from repositories, use apt-file, which maintains a separate Contents index. The Ubuntu apt-file manual explains its search and index commands.

Ubuntu apt-file search output pairing package names with matching file paths
Archived apt-file output shows file paths inside packages. apt-file is a separate tool, and its package-file index must be refreshed before searching.

The archived output shows the package-and-path format, not which versions your enabled repositories offer. If the file is already on your system, dpkg-query checks its installed owner.

Check the candidate source before installing

Before you choose a package, inspect the candidate and the repository that supplies it. A matching name is useful only when the source is one you intended to use.

apt-cache policy curl

If you later remove the package, check the difference between apt remove and purge before choosing the cleanup command. For commands beyond package search, see the broader apt command reference.

Common questions about apt search

What does apt search look for?

apt search checks package metadata in the local lists for enabled sources. Matches can come from package names or descriptions.

How do I search only package names?

Use apt-cache search –names-only with a term. Add ^ at the start and $ at the end when you want an exact package-name match.

Does apt search install a package?

No. apt search reads package indexes and displays matches. Installing a package is a separate command that changes the system.

How do I find which package owns a file?

Use dpkg-query -S for a path on your system. apt-file searches a separate index of files in repository packages.