O'Reilly logo

Ubuntu Hacks by Bill Childers, Kyle Rankin, Jonathan Oxer

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Hack #58. Search for Packages from the Command Line

When you aren't exactly sure which Ubuntu package has the files you need, use these handy command-line tools to find out.

The Ubuntu package-management system is truly impressive. Simply choose a package name, and Ubuntu will automatically download and install it along with any dependencies it may have. What happens, though, when you don't know the exact name of the package you want to install? The graphical package manager Synaptic has a search tool, but there are two separate command-line tools, apt-cache and apt-file, that you'll find are even more powerful. Each tool suits a particular type of search. apt-cache lets you search for a package based on keywords (among some of its other uses), and apt-file allows you to search for a package based on files inside that package. Each approach is useful in different circumstances, and this hack introduces you to how to use both tools effectively.

Search for Packages Based on Keywords

The apt-cache tool is actually much more than a keyword-based package search utility. apt-cache is a general tool used to query and manipulate the apt package cache. To search within the apt package cache, use the search argument followed by one or more keywords. For instance, if you wanted to find packages having to do with Adobe's Acrobat Reader, you could run the following search:

$ apt-cache search acrobat reader xpdf - Portable Document Format (PDF) suite xpdf-utils - Portable Document Format (PDF) ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required