I know that both apt-get and aptitude are command line package management interfaces on Debian derived Linux, with different options, but I'm still somewhat confused. Under the hood, aren't they using the same APT system?

Why does Debian maintain these parallel tools? (Bonus question: what on earth is wajig?)

I know its not the correct answerer for you question but why cant you try synaptic? its very user frindly and does download and install dependencies automatically. Is gnome is not present on your system?
–
HemantAug 11 '10 at 7:12

@Wim because of the wajig portion of this question I decided to merge 244 into this question instead of the other way around
–
xenoterracide♦Sep 5 '10 at 20:44

1

Its worth noting that aptitude is slated for removal from the default install on the next version of Ubuntu (although you could always install it using apt-get afterwards)
–
Rob CowellFeb 16 '11 at 12:47

9 Answers
9

The most obvious difference is that aptitude provides a terminal menu interface (much like Synaptic in a terminal), whereas apt-get does not.

Considering only the command-line interfaces of each, they are quite similar, and for the most part, it really doesn't matter which one you use. Recent versions of both will track which packages were manually installed, and which were installed as dependencies (and therefore eligible for automatic removal). In fact, I believe that even more recently, the two tools were updated to actually share the same database of manually vs automatically installed packages, so cases where you install something with apt-get and then aptitude wants to uninstall it are mostly a thing of the past.

There are a few minor differences:

aptitude will automatically remove eligible packages, whereas apt-get requires a separate command to do so

The commands for upgrade vs. dist-upgrade have been renamed in aptitude to the probably more accurate names safe-upgrade and full-upgrade, respectively.

aptitude actually performs the functions of not just apt-get, but also some of its companion tools, such as apt-cache and apt-mark.

aptitude has a slightly different query syntax for searching (compared to apt-cache)

aptitude has the why and why-not commands to tell you which manually installed packages are preventing an action that you might want to take.

If the actions (installing, removing, updating packages) that you want to take cause conflicts, aptitude can suggest several potential resolutions. apt-get will just say "I'm sorry Dave, I can't allow you to do that."

There are other small differences, but those are the most important ones that I can think of.

In short, aptitude more properly belongs in the category with Synaptic and other higher-level package manager frontends. It just happens to also have a command-line interface that resembles apt-get.

Bonus Round: What is wajig?

Remember how I mentioned those "companion" tools like apt-cache and apt-mark? Well, there's a bunch of them, and if you use them a lot, you might not remember which ones provide which commands. wajig is one solution to that problem. It is essentially a dispatcher, a wrapper around all of those tools. It also applies sudo when necessary. When you say wajig install foo, wajig says "Ok, install is provided by apt-get and requires admin privileges," and it runs sudo apt-get install foo. When you say wajig search foo, wajig says "Ok, search is provided by apt-cache and does not require admin privileges," and it runs apt-cache search foo. If you use wajig instead of apt-get, apt-mark, apt-cache and others, then you'll never have this problem:

$ apt-get search foo
E: Invalid operation search

If you want to know what wajig is doing behind the scenes, which tools it is using to implement a particular command, it has --simulate and --teaching modes.

Two wajig commands that I often use are wajig listfiles foo and wajig whichpkg /usr/bin/foo.

One big issue I had with aptitude is that it takes a long time to get tab completions on package names (eg, aptitude install linux-im tab), while it is very fast for apt-get. There seems to be some caching present in the apt-get family that is lacking for aptitude.
–
levesqueSep 11 '12 at 1:49

5

aptitude also have the awesome aptitude search that you can use with very powerful search patterns. You have aptitude reinstall. You can also use the ncurses (terminal menu) interface to prepare complex package operations like partial upgrade, remove one package, freeze another one, upgrade this one, that you can then execute in a single operation... Oh, and it has an interactive conflict resolver.
–
TotorMar 21 '13 at 23:52

2

@Totor holy cow, using aptitude's ncurses interface to prepare commands just sold me on aptitude once and for all! (after years of thinking aptitude is worth doing, but typing apt-get from muscle memory)
–
TJ EllisOct 16 '13 at 16:19

2

...and aptitude also has aptitude download package-name to get the package .deb file!
–
TotorOct 18 '13 at 14:44

1

It's just one thing I have found that isn't in aptitude but are in apt-get, and that is apt-get --compile source package-name. apt-get build-dep package-name exist but I think that aptitude build-dep package-name do a better job.
–
AndersMar 10 '14 at 14:13

I've often wondered myself. Wikipedia highlights that the main distinguishing feature is that aptitude has a full screen text-mode (curses) interface. The fact that you can use most apt-get command arguments with aptitude itself is just a design decision to make it easier for apt-get users to move to aptitude and vice-versa.

I've never used wajig, but the documentation suggests that it's just a script which knows whether you're passing it a deb file (when it runs dpkg) or an apt package name (when it runs apt-get instead). Could you try it out and see if that is what it does?

aptitude remembers which packages were explicitly requested and which were only installed due to dependencies. It will automatically uninstall packages which were not explicitly requested when they are no longer needed.

apt-get treats packages requested explicitly and their dependencies the same.

This used to be true, but I know my apt-get has an apt-get autoremove command for removing packages installed only as dependencies. I don't know when this feature was added, but one website suggests it might have happened with Debian Lenny (June 2010).
–
GauravAug 19 '10 at 10:55

5

apt-get autoremove doesn't remove packages installed only as dependencies, it removes orphaned dependencies, which is a subtle difference; it can't tell whether a 'leaf' package was installed with intent or as a dependency so it leaves it, where aptitude would know and remove it.
–
pjzAug 19 '10 at 15:05

apt-get, as well as the various companion tools, use significantly less memory than respective command-line invocations of aptitude, and are a bit quicker. I was blissfully unaware of this until I tried upgrading the debian install on a wizened old pentium thinkpad with 32MB of ram. It would take an hour or two of swap-thrashing to run apt-get, which completed successfully; aptitude would fail after I think a longer period of time.

This distinction is more or less irrelevant on anything resembling a modern desktop system.

The underlying system is not just apt, but dpkg. This system is just as dumb as RPM, it can only handle the installation and administration of single packages. It tracks which installed files belong to which package.

apt handles the downloads of repositories, tracking of dependencies, and so on for all individual packages - which it then installs using dpkg. aptitude does the same, with a different interface.

Debian is not a monolithic entity, there are people with different opinions and the aptitude maintainer decided that apt-get had some shortcomings and wanted to build something better with aptitude. He improved the logic to find solutions for complex upgrade scenarios, added a GUI for the console, etc. And there's more than just apt-get and aptitude, see my article apt-get, aptitude, … pick the right package manager for you.

I'm not sure if this still holds but the bleeding edge Debian developer Joey Hess always used to advocate aptitude over apt-get. Of course things to change as software evolves. Apt-get now handles dependencies better than it used to.
From http://lists.debian.org/debian-user/2004/04/msg03138.html

Date: Tue, 20 Apr 2004 22:27:12 -0400
From: Joey Hess

Nine reasons why you should be using aptitude instead of apt-get or dselect.

aptitude can look just like apt-get

If you run 'aptitude update' or 'aptitude upgrade' or 'aptitude
install', it looks and works just like apt-get, with a few enhancements.
So there is no learning curve.

(If you're a dselect user, learning curve is obviously not one of your
problems.)

aptitude tracks automatically installed packages

Stop worrying about pruning unused libraries and support packages from
your system. If you use aptitude to install everything, it will keep
track of what packages are pulled in by dependencies alone, and remove
those packages when they are no longer needed.

aptitude sanely handles recommends

A long-standing failure of apt-get has been its lack of support for
the Recommends relationship. Which is a problem because many packages
in Debian rely on Recommends to pull in software that the average user
generally uses with the package. This is a not uncommon cause of
trouble, even though apt-get recently became able to at least mention
recommended packages, it's easy to miss its warnings.

Aptitude supports Recommends by default, and can be confgigured to
support Suggests too. It even supports installing recommended packages
when used in command-line mode.

use aptitude as a normal user and avoid hosing your system

Maybe you didn't know that you can run aptitude in gui mode as a regular
user. Make any changes you'd like to try out. If you get into a real
mess, you can hit 'q' and exit, your changes will not be saved.
(Aptitude also lets you use ctrl-u to undo changes.) Since it's running
as a normal user, you cannot hose your system until you tell aptitude to
do something, at which point it will prompt you for your root password.

aptitude has a powerful UI and searching capabilities

Between aptitude's categorical browser and its great support for
mutt-style filtering and searching of packages by name, description,
maintainer, dependencies, etc, you should be able to find packages
faster than ever before using aptitude.

aptitude makes it easy to keep track of obsolete software

If Debian stops distributing a package, apt will leave it on your system
indefinitly, with no warnings, and no upgrades. Aptitude lists such
packages in its "Obsolete and Locally Created Packages" section, so you
can be informed of the problem and do something about it.

aptitude has an interface to the Debian task system

Aptitude lets you use Debian's task system as it was designed to be
used. You can browse the available tasks, select a task for install, and
then dig into it and de-select parts of the task that you don't want.
apt-get has no support for tasks, and aptitude is better even than
special purpose tools like tasksel.

aptitude supports multiple sources

If your sources.list is configured to make multiple versions of a
package available, aptitude lets you drill down to see the available
versions and pick a non-default version to install. If a package breaks
in unstable, just roll it back to the version in testing.

aptitude logs its actions

Aptitude logs package it installs, upgrades, and removes to
/varlog/aptitude, which can be useful to work out why things started
breaking after yesterday's upgrade, or when you removed a partiticlar
package.