The Ubuntu Software Center allows you to easily add and remove programs in Ubuntu. However, each Linux distribution has a different graphical method for adding and removing software. If you prefer using the keyboard, you can install and uninstall software using the command line.

To use the command line to install and uninstall software, you need to know the name of the package you want to install or uninstall. The Advanced Packaging Tool (APT) is the package management system used by Debian-based Linux distributions, such as Ubuntu. The command line program “apt-cache” is used by the APT system to maintain its database and you can use apt-cache to find out information from the metadata associated with the packages in the system.

NOTE: When we say to type something in this article and there are quotes around the text, DO NOT type the quotes, unless we specify otherwise.

Using apt-cache

To use apt-cache to list all the available packages in the system, type the following command at the prompt and press “Enter”.

apt-cache pkgnames | less

Note that we added “| less” to the end of the command. This pipes the output to the “less” command which allows you to press the up and down arrows to scroll through the list one item at a time, or press the “PgUp” and “PgDn” keys to scroll through the list one screen at a time. Piping the output to “more” (“| more”) instead of “less” allows you to press “Enter” to advance one line at a time once one screen of results displays.

The first screen of results displays. Use the arrow keys to move up or down or press “Enter” to show the next screen of results. Press “q” to exit the “less” command and return to the prompt.

If you know the beginning of the package name, you can search using that text to narrow the search. For example, to display all packages that start with the word “fire”, type the following command at the prompt and press “Enter”.

apt-cache pkgnames fire

Al packages starting with “fire” display. Again, we piped the command to “less” so we can easily scroll through the results.

To display information about a specific package, such as the package version number, check sums, size, installed size, and category, use the “show” option, as shown in the following example.

apt-cache show firefox

Dependencies for a package are what the package needs to already be installed on the system in order for the package to function. Reverse dependencies for a package are which other packages rely on this package to function. To see the dependencies and reverse dependencies for a package, use the “showpkg” option. For example, type the following command at the prompt and press “Enter” to find out the dependencies and reverse dependencies for Firefox.

apt-cache showpkg firefox

Here’s a list of packages that depend on Firefox to function…

…and the list of other packages that Firefox depends on to function.

To view overall statistic about the package cache, such as the number of different types of packages, use the “stats” option. Type the following at the prompt and press “Enter”.

apt-cache stats

To find out package names and their associated descriptions, use the “search” option. For example, to view the descriptions for the packages related to the minesweeper game for GNOME, type the following command at the prompt and press “Enter”.

apt-cache search gnome-mines

Using axi-cache

The “axi-cache” command works similarly to the “apt-cache” command, but provides more descriptive results, sorted by relevancy. As an example, we searched for all packages with “fire” in the name using the following command.

axi-cache search fire

The first 20 results are displayed.

To view additional results, enter “axi-cache more” on the command line.

The usage of “axi-cache” is similar to “apt-cache”. For more information about using “axi-cache”, type “axi-cache help” at the prompt and press “Enter”.

Profile Photo for Lori Kaufman Lori Kaufman
Lori Kaufman is a technology expert with 25 years of experience. She's been a senior technical writer, worked as a programmer, and has even run her own multi-location business.
Read Full Bio »