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.
- How to search for packages with apt
|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 |
|Conventions|| # - requires given linux commands to be executed with root privileges either directly as a root user or by use of |
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
- 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
- If you get a ton of results, you could always use
grepto narrow the search further, or pipe to
moreso your terminal doesn't get flooded with output.
$ apt search package-name | grep specific-name AND/OR: $ apt search package-name | less
apt-cache searchcommand 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
- 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
apache2in the name. This will show a list of packages that begin with the text "apache2".
$ apt-cache pkgnames apache2 apache2-ssl-dev apache2-suexec-pristine apache2-data apache2-bin apache2-dev apache2-doc apache2-suexec-custom apache2 apache2-utils
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
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.