Quick Links

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.

01_aptcache_apt_cache_pkgnames_command_with_less

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.

02_aptcache_one_screen_of_pkgnames_using_less

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

03_aptcache_using_pkgnames_option_with_name_text

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

04_aptcache_list_of_packages_with_text_in_name

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

05_aptcache_show_option_for_apt_cache

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

06_aptcache_using_showpkg_option

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

07_aptcache_reverse_dependencies_showpkg_option

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

08_aptcache_dependencies_showpkg_option

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

09_aptcache_using_stats_option

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

10_aptcache_using_search_option

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.

11_axi_cache_search

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

12_axi_cache_more

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”.