apt and aptitude

Steve Lamb grey at dmiyu.org
Mon Sep 8 00:20:09 UTC 2008


On Sun, Sep 07, 2008 at 07:59:18PM -0400, Jason Wilson wrote:
> Which is better and why?  Steve, you mentioned that you suggested aptitude 
> over apt. How come?

    The main reason is that aptitude will mark packages it has automatically
installed as such.  It then will track the dependacies against that package
and if no packages depend on it then it will automatically be removed.

    Take the apache2 example that spawned this question.  When you install
apache2 you're not installing just apache2.  Here's the dependancy line:

{grey at igbuntu:~} apt-cache show apache2 | grep Depends:
Depends: apache2-mpm-worker (>= 2.2.8-1ubuntu0.3) | apache2-mpm-prefork (>=
2.2.8-1ubuntu0.3) | apache2-mpm-event (>= 2.2.8-1ubuntu0.3)

    It will install ione of those three packages if none of them are present.
apache2-mpm-worker, apache2-mpm-prefork or apache2-mpm-event.  Let's say it is
prefork.

{grey at igbuntu:~} apt-cache show apache2-mpm-prefork | grep Depends:
Depends: apache2.2-common (= 2.2.8-1ubuntu0.3), libapr1, libaprutil1, libc6
(>=2.4), libpcre3 (>= 7.4)

    It will install those packages if none are present... and so on and so
forth for every package on down the line.  

    Now, when you install apache2 with apt it will install apache2-mpm-prefork
(well, probably worker but let's stick with the example) which in turn
installs apache2.2-common.  When you uninstall apache2 it leaves
apache2-mpm-prefork and apache2.2-common.  It has no idea that those were
installed to satisfy a dependancy.

    Aptitude, on the other hand, will install apache2 then install
apache2-mpm-prefork marked as "automatic" and apache2.2-common marked as
"automatic".  When you remove apache2 it will find that apache2-mpm-prefork no
longer has dependancies against it and remove it.  Then it'll find that
apache2.2-common has no dependancies and remove it, too.

    Generally aptitude keeps a cleaner system.  However, as you can see from
my examples it's good to keep your apt-fu up to par.  apt-cache is a great
tool for noodling around for packages if you're comfortable with the command
line.  Also note that apt-get and aptitude; while mostly compatible, do things
slightly different so it's best not to mix the two.

-- 
         Steve C. Lamb         | But who can decide what they dream
       PGP Key: 1FC01004       |      and dream I do
-------------------------------+---------------------------------------------
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <https://lists.ubuntu.com/archives/ubuntu-users/attachments/20080907/c65c8c02/attachment.sig>


More information about the ubuntu-users mailing list