The aptitude command is another package manager for Ubuntu and Debian. The utility allows you to do everything the same as apt, but except for the command line, it has a pseudo-graphical interface based on ncurses. With this tool, you can install and uninstall programs, update your system, view information about packages and their dependencies, search, and more.
This package manager has recently become not very popular, because it does almost everything that apt does and also from the command line, but it is sometimes used. In this short article, we will look at what this utility is, what are its advantages and how to use it.
If the program is not yet installed on your system, you can install it by running the following command:
sudo apt install aptitude
How to use Aptitude in the terminal
This command will work on most Debian and Ubuntu based distributions. As for Fedora, CentOS, and others using RPM, you don’t need to use aptitude there. Although you can install the program there.
1. Aptitude Syntax
If you run the program without parameters, a pseudo-graphical interface will open:
However, you can pass various options to it in order to use the program instead of apt:
$ sudo aptitude command options
We will talk about the possibilities of the pseudo-graphical interface later. Until then, teams.
2. aptitude Commands
Despite the presence of a pseudo-graphical interface, aptitude has the same commands as apt. In addition, there are commands that apt does not have. Let’s first look at the available commands:
- install – install one or more packages;
- remove – remove a package;
- reinstall – reinstall the package;
- build-depends – install dependencies needed to build a package from source;
- markauto – mark a package as installed automatically;
- unmarkauto – mark a package as manually installed;
- hold – disable package update;
- unhold – allow package update;
- update – update the list of available packages, similar to the apt update command;
- safe-upgrade – upgrades packages to a new version if the upgrade does not require the removal of other packages;
- full-upgrade – upgrades all packages to a new version, if a package needs to be removed to upgrade another, it will be removed;
- search – search for packages, and much more convenient than apt;
- show – show information about the package;
- source – downloads a package with the source code of the program;
- versions – displays available versions of the package;
- why – shows why the specified package is installed on the system;
- why-not – shows why the package cannot be installed;
- clean – cleans the /var/cache/apt/archives folder;
- download – download .deb package, but don’t install it;
- help – display help for the program.
These are the basic aptitude commands you can use. Not all commands are listed here, but only the most interesting ones. The rest you can see in the man pages:
3. Search for packages
If you want to find the exact package name with aptitude, use the search command. For example, for the krita program :
aptitude search krita
Searching in aptitude is much more convenient than apt. The program displays exactly what you are most likely interested in. There won’t be a bunch of different libraries listed here. But that is not all. By default, aptitude searches by name. But you can search by other parameters using search templates. The syntax for using them is:
$ sudo aptitude search “?pattern(pattern)”
The pattern starts with a question mark “?” and contains in parentheses the parameter by which to search. Let’s take a look at the main templates you can use:
- ?name – search by name;
- ?description – search by description;
- ?architecture – search by architecture;
- ?automatic – search for packages installed automatically;
- ?conflicts – search for packages that conflict with the specified one;
- ?garbage – searches for packages installed automatically, not required by any of the packages installed manually;
- ?installed – search among installed packages;
- ?upgradable – search among packages that can be upgraded;
There are other patterns as well. You can find them in the official documentation. For example, let’s try to search for packages by description. In the description of which contains the word gimp:
aptitude search "?description(gimp)"
Other search patterns work similarly. Each search pattern has a short version, which consists of the ~ sign and one letter. For example, for ?descriptio n it is ~d :
aptitude search "~dgimp"
But the full version, although longer, looks clearer.
4. Installing and removing packages
Before installing any package, update the package lists in the repositories:
sudo aptitude update
To install a package, use the install command. Earlier we found the krita package. Let’s install it:
sudo aptitude install krita
The installation must be confirmed, just like in apt:
If a package needs to be reinstalled, use the reinstall command:
sudo aptitude reinstall krita
To remove a package, run the remove command:
sudo aptitude remove krita
This command will only remove the package files, manually created configuration files will remain, to remove everything use the purge command:
sudo aptitude purge krita
After that, the package will be completely removed.
5. Package information
The information that can be viewed with aptitude is a little more detailed than with apt. You can display general information about a package with the show command :
sudo aptitude show nautilus
Another interesting command with information is why. It shows why this package is installed on the system:
aptitude why nautilus
Indicates that the ubuntu-desktop-minimal package depends on the nautilus package. You can also see why the selected package cannot be installed:
In this case, the unsigned kernel conflicts with the regular kernel, on which many packages depend.
Using the aptitude GUI
1. Launch and interface
As I said above, to run a program with a pseudo-graphical interface, you need to run it without parameters:
The program window is divided into several parts. These are the menu, tab bar, main work area, and notification area. You can move around the workspace using the up/down and right/left arrow keys. To open the menu, press Ctrl+T and use the same arrows to move between tabs and items:
Now let’s talk about finding and installing packages.
2. Search for packages
By default, the workspace contains categories of programs. You can open them and search for packages there by simply scrolling through them using the arrows. For example, you can open the Tasks section and find the mail-server metapackage there, which includes postfix, dovecot, mutt, and a few more packages:
Similarly, you can search for packages in other sections if you know where they are. Or you can search for packages using the hot key / . For example, let’s find the exim package:
You can use the n key to find the next occurrence of a package . Search patterns also work here, which were described in the section on the command line.
3. Install packages
Before installing a package, you need to update the package lists from the repositories. To do this, press the u button :
Then find the package using one of the above methods and put the cursor on it. For example, let’s install the Exim mail server . In order to mark a package for installation when the cursor is on it, type the symbol + on the keyboard to do this, press Shift += . After that, the package will be highlighted in green:
If this package conflicts with any of the already installed packages, a red line will appear at the bottom of the window with a description of the problem and solutions. You can switch between them using the “,” and “.” . And to apply the solution, press “!” .
Once all packages to be installed are checked, the changes must be applied. To do this, press the g button . A window will open with a preview of the change:
If you change your mind about installing one of the packages, click the “-“ button . Similarly, packages are marked for removal. When you’re done, press g again to complete the installation. Removing packages is done in the same way.
In this article, we looked at what the aptitude command does and how to use it to install packages. As you can see, everything is quite convenient, and its pseudo-graphical interface is quite similar to Synaptic in terms of the package installation process. What package manager do you prefer? Write in the comments!