On Ubuntu, why "sudo apt-get" sometimes and "sudo aptitude" other times?

I was trying to figure out how to install libgtk2.0-dev and found that I have to use

sudo aptitude install

instead of

sudo apt-get install

Why these two different ways of getting stuff?


Solution 1:

apt-get and aptitude are both frontends to dpkg. Use one or the other but be consistent. Aptitude is newer and is suppose to be easier to use. It also unifies some of the apt-* functions. You can use aptitude to search and install while with apt-* you need apt-get and apt-cache for installation and searching respectively.

I usually replace all apt-get examples with aptitude when copying & pasting commands.

Run aptitude without any options to get an interface for selecting packages. I don't ever use it so I don't know how friendly it is.

Solution 2:

apt-get and aptitude are both interfaces to dpkg, the Debian package manager.

aptitude came later than the apt- suite of commands and has some usability features not present in the latter, but I have yet to come across a case where you have to use one over the other.

The Wikipedia entry for aptitude states that it started out as a front-end to the apt- suite:

aptitude is a front-end to the Advanced Packaging Tool (APT). It displays a list of software packages and allows the user to interactively pick packages to install or remove. [...] Even though aptitude is a single executable, it provides CLI functionality similar to that of apt- family of tools (apt-get, apt-cache, apt-listchanges, etc). Aptitude also emulates most apt-get command line options, allowing it to act as a drop-in replacement for some of the apt-get usages.

Solution 3:

Long-time Debian users have told me elsewhere that aptitude has it's own database that it maintains alongside the one that apt keeps. This means that using both interchangabley will result in some confusing things happening sometimes, particularly in aptitude when it seems to have a slightly stale copy of the package state. I have seen this happen: it results in things like packages you mysteriously can't remove or can't install.

The GUI program synaptic doesn't have this problem because it relies entirely on the apt database.

Solution 4:

Aptitude and apt-get serve the exact same purpose for Ubuntu Dapper and beyond. Prior to that, apt-get might not auto-remove things as it should.

Source: http://www.psychocats.net/ubuntu/aptitude