How to search a package on Ubuntu

Learning how to search a package on Ubuntu is crucial in finding and installing new packages. Before installing a package on Ubuntu it’s useful to have some information on it such as:

  • the exact package name
  • package version
  • package details
  • package description
  • alternatives

This tutorial teaches you how to search for a package on Ubuntu by using the following tools:

  • apt-cache search
  • apt search
  • apt show
  • aptitude search

Prerequisites

To follow up with the commands in this tutorial you need an Ubuntu machine and access to the terminal.

Update Ubuntu

The tools shared in this tutorial use the APT package list to search for a package. To make sure your search results provide you with the latest stable version of each package, you need to update your Ubuntu repositories.

To update Ubuntu type:

sudo apt update

How to search a package on Ubuntu with apt

apt is used to manage packages on Ubuntu and other Debian based distros. It can also be utilized to search the package list for a package.

How to search a package on Ubuntu with apt-cache

You don’t need to know the full name of the package when working with apt-cache search. Use apt-cache to search for a package by keyword:

apt-cache search nmap 

The apt-cache search displays a list of packages that match the search keyword and provides a small description behind each one of them.

how to search a package with apt-cache on ubuntu
Search a package with apt-cache

How to search a package on Ubuntu with apt search

Although both apt-cache search and apt search provide similar information when searching for a package on Ubuntu, the former one gives additional information such as the architecture of the package and its version.

To search a package with apt on Ubuntu type:

apt search nmap

How to search a package on Ubuntu with apt show

Use apt show to search for full metadata on a package on Ubuntu:

apt show nmap

As you can see from the results below the apt show command gives important and very detailed information on the package you are searching for.

Search a package with apt show

To use apt show you need the full name of the package you are searching for, otherwise you will get an error.

How to search a package on Ubuntu with aptitude

aptitude can also be used to search for a package on Ubuntu. It provides a clean output and prefixes each one of the packages with a letter indicating its state, for example:

  • i for installed
  • p for purged
  • c for config
  • v for virtual

aptitude is not installed by default on Ubuntu. To install aptitude on Ubuntu type:

sudo apt install aptitude

To search for a package on Ubuntu with aptitude type:

aptitude search nmap
Search a package with aptitude

Final thoughts

Although the tools shared in this tutorial serve the same purpose you need to be aware when to use which. Use apt-cache search and apt search when you don’t know the full name of the package you are looking for. In case you need detailed information on the package use apt show.


Leave comment

Your email address will not be published. Required fields are marked with *.