In this guide, we will be showing you how you can search for packages on Ubuntu while using the terminal.
If you are interested in what packages you can install to your Ubuntu system, you can use the apt package manager’s inbuilt search functionality.
This functionality allows you to search the entire apt package list quickly. Using this, you will get the package name, version, architecture, and full description.
Ubuntu even offers an online search engine that you can use to search for installable packages. However, this only includes the official repositories and not any additional ones you may have added.
For example, installing Node.JS to your Ubuntu system often adds the Nodesource repository. If you want to search that repository for packages as well, you will need to search the local package cache instead.
Luckily, the built-in tools to search for packages are straightforward to use, even for people who aren’t too familiar with using the terminal.
By the end of this quick guide, you should hopefully have a good understanding of how easy it is to search for Packages on Ubuntu.
Searching for Packages in Ubuntu using the Terminal
Over the following sections, we will explore how you can search for packages on the Ubuntu operating system.
We will be exploring two methods in particular. The first will be to use the “
apt search” command. The second is to use grep and the “
apt list” command.
Both of these methods have their advantages and disadvantages, but they are essentially using the same underlying data, just presenting them differently.
For any of these methods, you will need to open the terminal on your Ubuntu system. The easiest way to do this on desktop is to press CTRL + ALT + T.
Before you Begin Searching for Packages
Now before we rush into how exactly you search for packages on an Ubuntu operating system there is something we should first cover.
Like when installing packages, it is recommended to update the package list. APT keeps a cache of the package list on your system. This cache is also what APT uses when you perform a search.
An out-of-date package list means you might be finding packages that are no longer available or seeing versions that don’t match up with what you can download.
Luckily, updating the package list is as straightforward as using the following command.
sudo apt update
Using APT Search to Search for Packages on Ubuntu
The primary way to search packages on Ubuntu while using the terminal is to use APT’s search command.
This command is super straightforward to utilize and lets you easily search the entire package list contents.
Searching the Entire Contents of the Ubuntu Package List
To search the package list on Ubuntu, all you need to do is use the following command.
All you need to do is use “
apt search” followed by the package name you seek.
It doesn’t have to be an exact name, as when used this way, apt will search the package name, version, dependencies, and description.
apt search <PACKAGENAME>
For example, if we want to search for all PHP packages on Ubuntu, you can use the following command.
apt search php
Searching Packages on Ubuntu using Only the Name
If you want to be more exact and only search package names, you will want to use the “
This is useful when you don’t want to look through packages that might have your package name within its description.
apt search --names-only <PACKAGENAME>
For example, to search only for packages that contain the name “
PHP“, you would use the command below.
apt search --names-only PHP
Using APT List to Search for Packages
The other method for searching packages on Ubuntu that we will be exploring is by using “
This method has its advantages in allowing us to filter installed or upgradeable packages with relative ease. The downside is that it does require us to use grep when searching for a particular package name.
Additionally, you don’t get to search the package descriptions either when using this method.
Listing All Available Packages on Ubuntu
Unless you grab the entire package list and manually search through it, this is probably not the command you want to run.
By running this command within the terminal, the name of every package will be printed to the terminal in alphabetical order.
Searching the Package List using Grep
Now, if you want to search this list easily from within the terminal, we can utilize the grep command and a pipe.
By using grep, we can get it only to print out packages that contain our phrase.
apt list | grep "<PACKAGE NAME>"
For example, to search for packages that contain the name “
apache2“, we can utilize the following.
apt list | grep "apache2"
Only Searching Installed Packages on Ubuntu
If you only want to search for packages on Ubuntu that are already installed, then you need to include the “
Using this alongside grep will allow you to easily find a package you already have installed on your Ubuntu system.
apt list --installed | grep "<PACKAGE NAME>"
For example, if you want to search for a package with the name “
apache2“, you would use the following command.
apt list --installed | grep "apache2"
Only Search Upgradable Packages
Likewise, if you want to search for packages that are installed but upgradeable, then you can utilize the “
Like our previous few sections, you will likely want to use grep to quickly search through the numerous packages this command might spit out.
apt list --upgradable | grep "<PACKAGE NAME>"
For example, if we wanted to see whether Docker has a newer version available on the Ubuntu package list, you could use the following.
apt list --upgradeable | grep "docker"
At this stage, you will hopefully have a good idea of how to search for packages on the Ubuntu operating system.
Knowing how to search for packages lets you quickly see what you can install to your system.
Please leave a comment below if you have any questions about searching for packages on your system.
If you found this guide to be helpful, we highly recommend checking out our many other Ubuntu tutorials.