Master the Linux ‘aptitude’ Command: A Comprehensive Guide

Peter Hou
3 min readJun 11, 2023

As a package manager for Debian-based systems, aptitude offers advanced features like automatic dependency resolution and an interactive interface, making package management much simpler and intuitive. The command has multiple options and parameters that allow you to tailor its operations based on specific needs. Use cases range from updating packages, installing or removing them, to even holding them at a specific version. Its ability to handle complex dependencies better than its counterparts like apt-get is commendable, but remember, it's crucial to avoid mixing it with other package managers to prevent unexpected results. This article guides you through the use of aptitude, aiming to boost your confidence and efficiency in managing your Linux system.

Instructions

This article provides a detailed and comprehensive instruction for the Linux aptitude command. It covers its history, purpose, usage, parameters, common use cases, tricky skills, and other noteworthy aspects. By the end of the article, you will have a solid understanding of aptitude and be able to use it proficiently in various scenarios.

History

aptitude is a package manager for Debian and its derivatives like Ubuntu. It was developed as a replacement for dselect and apt-get and has been around since 2002. It offers some improvements over apt-get and provides a more user-friendly interface.

When and why to use it

aptitude was designed to simplify the process of managing packages on Linux distributions. It helps users to install, upgrade, and remove software packages on Linux systems. Unlike apt-get, aptitude can resolve dependencies automatically and can provide a more interactive interface, making it easier for users, especially beginners, to handle packages.

How to use it

Using aptitude is straightforward. The general syntax is aptitude [options] command, where options and command refer to the options and commands that aptitude supports.

$ aptitude update
Reading package lists... Done

The commonly used parameters

  • V Show which versions of packages are to be installed.
$ aptitude -V install <package_name>
Will install specific package version
  • -y Assume "yes" as answer to all prompts and run non-interactively.
$ aptitude -y install <package_name>
Automatically agree to all prompts

Other supported parameters

There are many other parameters that aptitude supports, each with its unique purpose. Some of these include -D (Only download packages, do not install/upgrade anything), -F (Specify the output format), -P (Display the progress indicator), -R (Do not attempt to install Recommends), -S (Specify alternative configuration file), and many more.

Most common use cases

aptitude is mainly used for package management. Some of the most common use cases include updating the package list (aptitude update), installing new packages (aptitude install <package_name>), removing packages (aptitude remove <package_name>), and upgrading all upgradable packages (aptitude upgrade).

$ aptitude install <package_name>
Will install specific package

The tricky skills

One useful feature of aptitude is its ability to hold a package at a particular version, preventing it from being upgraded. You can achieve this by using aptitude hold <package_name>. Another handy feature is its search functionality. You can use aptitude search <search_term> to find packages related to a specific term.

$ aptitude hold <package_name>
Package <package_name> set on hold.

What needs to be noted

One thing to be aware of is that aptitude uses a different resolver than apt-get. While aptitude generally does a better job at resolving complex dependencies, the downside is that it might cause unexpected results if used interchangeably with apt-get.

Conclusion

aptitude is a powerful and user-friendly package manager for Debian-based systems. With its intuitive interface and rich feature set, it significantly simplifies the process of managing packages on Linux. However, it's essential to understand its unique aspects and potential caveats when using it in conjunction with other package managers.

--

--

Peter Hou

I am a Senior Software Engineer and tech lead in a top tech company.