Ubuntu Server 18.04 – Searching for packages

How to install and create applications with Docker Compose

Unfortunately, the naming conventions used for packages in Ubuntu Server aren’t always obvious. Worse, package names are often very different from one distribution to another for even the same piece of software. While this tutorial and other tutorials online will outline the exact steps needed to install software, if you’re ever on your own, it really doesn’t help much if you don’t know the name of the package you want to install. In this section, I’ll try to take some of the mystery out of searching for packages.

In the previous section, we went over searching for Snap packages already, so I won’t repeat that here. The APT suite of utilities also has a means of searching for packages as well, which is the apt search command.  We can use the following command to search for packages, by providing a keyword:

apt search <search term> 

The output from this command will show a list of packages that match your search criteria, with their names and descriptions. If, for example, you wanted to install the PHP plugin for Apache and you didn’t already know the name of the associated package, the following would narrow it down:

apt search apache php 

In the output, we will get a list of more than a handful of packages, but we can deduce from the package descriptions in the output that libapache2-mod-php is most likely the one we want. We can then proceed to install it using apt, as we would normally do. If we’re not sure whether or not this is truly the package we want, we can view more information with the apt show command:

apt-cache show libapache2-mod-php 
Showing the info of a Debian package

With this command, we can see additional details regarding the package we’re considering installing. In this case, we learn that the libapache2-mod-php package also depends on PHP itself, so that means if we install this package, we’ll get the PHP plugin as well as PHP.

Another method of searching for a Debian package (if you have a web browser available), is to connect to the Ubuntu Packages Search page at http://packages.ubuntu.com/ where you can navigate through the packages from their database for any currently supported version of Ubuntu. You won’t always have access to a web browser while working on your servers, but, when you do, this is a very useful way to search through packages, view their dependencies, descriptions, and more.

Using the apt-cache search command, as well as the snap find commands, should get you quite far in the process of determining the name of the packages you want to install. Package management skills come over time, so don’t expect to automatically know which packages to install right away. When in doubt, just perform a Google search and research the documentation of the software you want to run and learn how to install it in Ubuntu. Typically, the instructions will lead you to the correct commands to use. The examples we’ll go over during the course of this tutorial will guide you through the most common use cases for Ubuntu Server.

Comments are closed.