56

I don't get why there are two different programs in a minimal install to install software. Don't they do the same thing? Is there a big difference? I have read everywhere to use aptitude over apt-get but I still don't know the difference

9 Answers 9

48

aptitude is a wrapper for dpkg just like apt-get/apt-cache, but it is a one-stop-shop tool for searching/installing/removing/querying. A few examples that apt might not supply:

$ aptitude why libc6
i   w64codecs Depends libc6 (>= 2.3.2)
$ aptitude why-not libc6
Unable to find a reason to remove libc6.

$ aptitude show libc6
Package: libc6
State: installed
Automatically installed: no
Version: 2.9-4ubuntu6
Priority: required
Section: libs
Maintainer: Ubuntu Core developers <[email protected]>
Uncompressed Size: 12.1M
Depends: libgcc1, findutils (>= 4.4.0-2ubuntu2)
Suggests: locales, glibc-doc
Conflicts: libterm-readline-gnu-perl (< 1.15-2), 
tzdata (< 2007k-1), tzdata-etch, nscd (< 2.9)
Replaces: belocs-locales-bin
Provides: glibc-2.9-1
Description: GNU C Library: Shared libraries
 Contains the standard libraries that are used by nearly all programs 
 on the system. This package includes shared versions of the standard 
 C library and the standard math library, as well as many others.
2
  • 10
    not to mention: $ aptitude changelog bash
    – pgs
    Jun 6, 2009 at 16:46
  • Other tricks that aptitude knows that even latest apt cannot do: aptitude search '~i linux' searches for packages with linux in name or description that are installed; aptitude search '~o' lists obsolete packages (installed packages that are no longer provided by any repository); aptitude search '!~M ~i' shows packages that are not marked as automatically installed; aptitude search '~i lib.*-dev' shows installed development libraries and you can replace search with markauto or unmarkauto to mark these packages as automatically or manually installed. Jan 15, 2019 at 14:28
45
mikeage@linode ~$ aptitude -h | tail -n 1
              This aptitude does not have Super Cow Powers.
mikeage@linode ~$ apt-get -h | tail -n 1
                   This APT has Super Cow Powers.
mikeage@linode ~$ aptitude moo
    There are no Easter Eggs in this program.
mikeage@linode ~$ apt-get moo
         (__)
         (oo)
   /------\/
  / |    ||
 *  /\---/\
    ~~   ~~
...."Have you mooed today?"...
mikeage@linode ~$ aptitude -v moo
There really are no Easter Eggs in this program.
mikeage@linode ~$ aptitude -vv moo
Didn't I already tell you that there are no Easter Eggs in this program?
mikeage@linode ~$ aptitude -vvv moo
Stop it!
mikeage@linode ~$ aptitude -vvvv moo
Okay, okay, if I give you an Easter Egg, will you go away?
mikeage@linode ~$ aptitude -vvvvv moo
All right, you win.

                               /----\
                       -------/      \
                      /               \
                     /                |
   -----------------/                  --------\
   ----------------------------------------------
mikeage@linode ~$ aptitude -vvvvvv moo
What is it?  It's an elephant being eaten by a snake, of course. 
19

The official tool that is currently used within the Debian installer and recommended in the release notes is aptitude.

Aptitude offers a curses interface (when run without any parameter) and a command line interface that can do almost everything that apt-cache/apt-get does. It also has a better dependency resolver that let you browse between multiple solutions. Even when using the command line version, you can interact with the proposed solution and give supplementary orders or hints (like installing or removing a package that is recommended by another one).

But aptitude is based on the libapt library (it's not a direct wrapper of dpkg) and as such it depends on the apt package so you can't have aptitude installed without apt-get (which is also in the apt package).

$ dpkg --status aptitude| grep Depends
Depends: libapt-pkg-libc6.9-6-4.7, [...]
$ dpkg --status apt|grep Provides
Provides: libapt-pkg-libc6.9-6-4.7
$ dpkg --search /usr/lib/libapt-pkg-libc6.9-6.so.4.7 /usr/bin/apt-get
apt: /usr/lib/libapt-pkg-libc6.9-6.so.4.7
apt: /usr/bin/apt-get

To learn more on how apt/dpkg/aptitude interact you can check the diagram made by Daniel Burrows (aptitude's main author). Another diagram presents the information stored by the various package management tools: A map of the apt and dpkg state files.

You can also read my article apt-get, aptitude, … pick the right package manager for you

0
7

aptitude remembers which packages you deliberately installed and which have been automatically installed to satisfy dependencies. Upon removal of a package aptitude will remove those automatically installed packages to keep your system tidy. apt-get isn't that smart.

aptitude will quickly become an indispensable tool once you use different repositories with different versions of a package. Imagine you are working with backports.org or unofficial repositories like debian-multimedia.org. Then aptitude will show (at the bottom of the details page of a certain package) the available version number and allow you to select one.

If you get into a situation where programs conflict due to such usage of unofficial repositories you will see a "Broken: ..." display on the top. You can type l~b (limit / flag / broken) and just get a list of packages that conflict with each other. Makes it much easier to resolve the conflict manually.

Furthermore you can use "l" to limit the package list. Imagine you are looking for packages that start with "openoffice" then press "l" and type "^openoffice" (it's a regular expression) and you will see just those packages. Choose a "flat package list" from the menu and you will get reach your goal quickly.

The complete handbook is very large, offering you many more filters and possibilities. Even if you don't know them aptitude is a handy replacement for apt-get and you can use it with common parameters like:

aptitude install ... (install or upgrade a package)
aptitude remove ... (remove the binary portions of a package but preserve your /etc configuration)
aptitude purge ... (remove the package completely including your configuration)
3
  • 2
    Actually, as of Lenny, apt-get also tracks packages installed only as dependencies of something you explicitly asked for. I use aptitude myself, but apt-get autoremove now removes packages that were installed as dependencies of a package that has since been removed.
    – Telemachus
    Jun 7, 2009 at 20:41
  • Nowdays you can also use just apt and it can do a mixture of stuff that apt-get and apt-cache used to do. For example, apt search foo will list packages that contain foo in name or description. apt install foo will install package called foo if available and apt policy foo will list currently installed version and all available versions of package foo. Jan 15, 2019 at 14:44
  • The aptitude can still do more than apt but plain apt is often much faster. Jan 15, 2019 at 14:45
5

Aside from providing a pretty console UI when you run aptitude with no arguments, it combines the various apt-* commands (and dselect) into one utility..

To search for a package and install it, using apt-get:

apt-cache search somepkg
apt-get install somepkg

..but with aptitude it's the same command:

aptitude search somepkg
aptitude install somepkg

aptitude does have some additional features, like aptitude changelog somepkg and things like holding packages (to stop them being upgraded) - nothing you couldn't achieve via other commands/methods, it's just more unified and nice to use.

1
  • 3
    too bad it does not have an "apt-cache policy" equivalent.
    – hayalci
    Jun 6, 2009 at 15:20
4

as you know when you install a package if it needs other packages (dependencies) they will be downloaded and installed too. aptitude tracks, at the moment of install, the packages that come with the installed one so when you remove the latter aptitude will ask you for the removal of the other (now unused) "orphaned" dependencies. apt-get will keep them in your system silently if you remove the "main" package.

it looks like the latest versions of apt-get has a similar functionality: http://www.psychocats.net/ubuntu/aptitude

1
  • aptitude or apt does not in fact keep list of packages that were installed as dependencies for any given package. It simply tracks if a package was installed manually or automatically. And if a package has been marked as automatically installed and no other package Depends or Recommends it, it will be removed with apt autoremove or aptitude dist-upgrade. Jan 15, 2019 at 14:50
3

The biggest difference is that aptitude is designed to be interactive where the apt tools are better suited for scripting work. You can use the latter, i.e. the apt tools, interactively just fine with a lot more effort to get the same results that aptitude provides. If you had to settle on just one tool or the other for some reason then you need to decide how much effort you want to put into your package management.

1

One of the serious advantages of aptitude is its ability to calculate dependencies. Firstly it can handle complicated inter-dependencies without intervention by yourself, which often apt-get fails on. But if you don't like the solution it has presented you (and it will score its own solution to demonstrate how good it thinks it is), you can ask it to go away and come up with another solution to resolve the conflict.

It really does do some awesome package management.

1

The biggest difference is: type "aptitude" without any parameters.

It gives you a Text based user interface, you can use keybord to search/navigate etc. see information on dependencies, reverse dependencies, all available versions of a package, and you can do any package manager operation on them from that screen.

You can press "g" to review the changes, modify the package additions and removals if necessary, and apply all pending operations.

A great visual way of package management over an ssh connection or plain old terminal.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .