One of the most attractive features of running a Linux system is the instant access to thousands of packages that are able to be installed from the Linux distro's package manager.

Installing packages is really easy. That is, as long as you know the name of what you're trying to install. If you don't, then you can always search for installable packages. On distros that use the apt package manager, like Debian, Ubuntu, and Linux Mint just to name a few, this is done with the apt search command.

In this guide, we'll show you how to use the apt search command with multiple examples. You'll quickly learn to master the task of finding packages to install.

In this tutorial you will learn:
  • How to search for packages with apt
Using apt search to find relevant packages
Using apt search to find relevant packages
Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System Any Linux distro with apt
Software apt package manager
Other Privileged access to your Linux system as root or via the sudo command.
Conventions # - requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ - requires given linux commands to be executed as a regular non-privileged user

Search for a package with apt package manager

Use the following commands to search for a package with apt. Before starting, you should update your repository list, so all the results are relevant.

$ sudo apt update

Subscribe to our NEWSLETTER and receive latest Linux news, jobs, career advice and tutorials.

  1. The simplest way to search for a package is with the following syntax. This will look for any packages related to your search query, not just packages that contain the specific phrase in their name.
    $ apt search package-name
  2. If you get a ton of results, you could always use grep to narrow the search further, or pipe to less or more so your terminal doesn't get flooded with output.
    $ apt search package-name | grep specific-name
    $ apt search package-name | less
  3. The apt-cache search command is very similar, but will format the output differently. This is the preferred method if you were trying to script this task.
    $ apt-cache search package-name
  4. If you'd like to search just the names of packages, you can use the following synax. Here's an example where we search for packages with apache2 in the name. This will show a list of packages that begin with the text "apache2".
    $ apt-cache pkgnames apache2

That's all there is to it. Once you've identified the package you want to grab, you can download and install it with the usual apt install command.

$ sudo apt install package-name

Closing Thoughts

In this guide, we saw how to search for packages in apt package manager. This included using the apt search command and its close cousin apt-cache search. Using these commands, as well as grep, you should be able to quickly find the packages you need, and even have the commands to script out this functionality in the future if needed.

Submit your RESUME, create a JOB ALERT.
Subscribe to NEWSLETTER and receive latest news, jobs, career advice and tutorials.
Get extra help by visiting our LINUX FORUM or simply use comments below.