Tell me more ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?)

share|improve this question
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? – Hemant Aug 11 '10 at 7:12
I'm biased, but I think this question on the Ubuntu SE site might be relevant. – David Zaslavsky Aug 19 '10 at 7:38
3  
@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
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 Cowell Feb 16 '11 at 12:47

8 Answers

up vote 79 down vote accepted

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 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 provileges," 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 that show you.

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

share|improve this answer
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. – levesque Sep 11 '12 at 1:49
2  
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. – Totor Mar 21 at 23:52

I've often wondered myself. Wikipedia suggests that aptitude properly only refers to the ncurses-based interface, which itself uses apt-get in the background. 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?

Of course, the real difference is:

gaurav@fern:~$ apt-get moo
         (__) 
         (oo) 
   /------\/ 
  / |    ||   
 *  /\---/\ 
    ~~   ~~   
...."Have you mooed today?"...
gaurav@fern:~$ aptitude moo
There are no Easter Eggs in this program.
share|improve this answer
19  
No! aptitude has more. You forgot to put the endless -v flags to moo. (You can go upto -vvvvvv) – Umang Aug 19 '10 at 6:51
o.O! Brilliant. – Gaurav Aug 19 '10 at 9:52
3  
Don't forget the all important Super Cow Powers, which apt-get has but aptitude does not. (Try --help on both) – derobert Aug 20 '10 at 18:51

aptitude is the preferred program for package management from console both for package installations and package or system upgrades in Debian.

Here is an overview of the tool and the features it has over apt-get: http://www.debian.org/doc/FAQ/ch-pkgtools.en.html#s-aptitude

So, my advice is to just apt-get install aptitude :)

share|improve this answer
2  
The release notes say apt-get is now recommended over aptitude for upgrades to squeeze. – jrdioko Feb 9 '11 at 19:55

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.

So better use aptitude, this helps to keep your system clean.

share|improve this answer
2  
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). – Gaurav Aug 19 '10 at 10:55
3  
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. – pjz Aug 19 '10 at 15:05

They offer the same basic functionality: install and remove packages from the command-line.

Here's a more detailed comparison, posted on the Ubuntu Stack Exchange website: http://ubuntu.stackexchange.com/questions/1743/is-aptitude-really-better-than-apt-get/1749#1749

share|improve this answer
They are pretty similar, I can switch between them easy enough. – invert Aug 11 '10 at 8:48

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.

share|improve this answer

As mentioned be http://pthree.org/2007/08/12/aptitude-vs-apt-get/, aptitude has a much easier to use command-line interface.

Under the hood, aren't they using the same APT system? Yes.

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.

share|improve this answer

Both apt-get and aptitude rely on the APT library, yes.

See my answer on serverfault.com.

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.