Aptitude vs. apt-get: Which is the recommended (aka the "right") tool to use?
Solution 1
aptitude
and apt-get
work the same for many tasks, but for the most tricky cases, such as distribution upgrades (apt-get dist-upgrade
vs. aptitude full-upgrade
), they have different rules, and aptitude's rules are nearly always better in practice where they disagree.
The reason you see more documentation for apt-get
over aptitude
is mostly inertia: aptitude
has not been the recommended front end to APT for all that long, so much of the existing documentation hasn't been updated, and there are plenty of people who recognise the advantages of aptitude
over apt-get
but use apt-get
reflexively.
I've recently got to the point where I usually follow apt
with a i
and not a -
when I type.
Postscript Note that the rules used in apt-get
and aptitude
are moving targets - as Hubert notes in comments, the upgrade path recommended from Debian Lenny now uses apt-get
, not aptitude
. This reflects the fact that apt-get
keeps track of less state about the current package than aptitude
, and so does not need to worry about APT state not being "clean", and because apt-get
rules are smarter than they used to be. I still use and recommend aptitude
over apt-get
, but it is a more nuanced recommendation
Solution 2
aptitude
makes it convenient to show what programs in a search you already have installed on the system (with the help of grep
):
aptitude search flash | grep ^i
Actually, aptitude
's search is far more powerful than what you get piping through grep
, as it supports contextual searching:
e.g., this finds all packages with 'flash' in the package name that are installed:
aptitude search '~iflash'
An equivalent "long form" of the "short form" ~i
:
aptitude search '?installed(flash)'
Note that search patterns are free (unanchored) by default. To anchor them, you need to use anchor patterns '^
' (beginning of string) and/or '$
' (end-of-string).
To find all packages whose names start with either 'ttf' or 'font':
aptitude search '(^ttf|^font)'
(Note: this is a workaround for a bug in aptitude
, as the correct regex of '^(ttf|font)'
does not work properly -- it finds packages whose names start with 'ttf' or contain 'font'.)
Other nifty aptitude
features:
Show all packages with 'firmware' in their name that ALSO have 'wireless' in their description:
aptitude search 'firmware ~dwireless'
or long form:
aptitude search '?and(?name(firmware),?description(wireless))'
(Note: in the short form, space-delimited arguments are ANDed within quotes; if passed as separate argv[] commandline arguments they are ORed.)
p atmel-firmware - Firmware for Atmel at76c50x wireless networking chips.
p firmware-atheros - Binary firmware for Atheros wireless cards
...
p libertas-firmware - Firmware for Marvell's libertas wireless chip series
p zd1211-firmware - Firmware images for the zd1211rw wireless driver
~U
shows all packages that are Upgradeable from their current versions with new versions:
# aptitude update ; aptitude versions '~U'
Package virtualbox-4.1:
i 4.1.18-78361~Debian~squeeze 100
p 4.1.20-80170~Debian~squeeze <NULL> 500
Show packages that Recommend 'gcc-multilib'
$ aptitude search '~DRecommends:gcc-multilib'
i libc6-dev-i386 - Embedded GNU C Library: 32-bit development libraries for AMD64
Explain why 'fuse-utils' might need to be installed
$ aptitude why fuse-utils
i xorg Depends xterm | x-terminal-emulator
pi gnome-terminal Provides x-terminal-emulator
pi gnome-terminal Recommends gvfs
pi gvfs Depends libgdu0 (>= 2.29.90)
pi libgdu0 Depends udisks (< 1.1.0)
pi udisks Recommends ntfsprogs
pi ntfsprogs Depends fuse-utils (> 2.5.0)
(This example shows some of the craziness resulting from the default since Squeeze(?) of installing all "Recommends" packages. Installing gnome-terminal ends up installing ntfsprogs and fuse-utils, egad! I think most folks just want the terminal perspective and not the builtin NTFS integration, which is optional, unless they specified it.)
Find all packages that provide the service "mail-transport-agent":
$ aptitude search '?provides(mail-transport-agent)'
p citadel-mta - complete and feature-rich groupware server (mail transport agent)
...
p nullmailer - simple relay-only mail transport agent
p postfix - High-performance mail transport agent
i sendmail-bin - powerful, efficient, and scalable Mail Transport Agent
p ssmtp - extremely simple MTA to get mail off the system to a mail hub
p xmail - advanced, fast and reliable ESMTP/POP3 mail server
Show all package names that are installed, that are not either Essential or Automatically installed by dependencies:
$ aptitude search '~i!(~E|~M)' -F '%p'
Unfortunately, this stuff is rather poorly documented and hard to find, but here's the best reference (from the 'aptitude' maintainer).
Solution 3
According to the Debian GNU/Linux FAQ about package management, aptitude is more complex than apt-get and depends on the less complex package management tools apt-get and dpkg.
Therefore, for simpler needs, you can use the simpler tools, while for more complex needs, you can count on the more sophisticated tool (apitude).
Quoted from the Debian FAQ: "aptitude provides the functionality of dselect and apt-get, as well as many additional features not found in either program."
Solution 4
aptitude marks packages which where installed because of a dependency with the auto tag. If you now purge or remove a package, aptitude will automatically remove the auto installed packages which aren't used anymore alongside the package you want to purge or remove.
This is the main reason why I personally think that aptitude is always better then apt.
Solution 5
There's no right tool, you can mix & match both depending on the one that you find most convenient for the task at hand. aptitude is a great tool for testing/sid users but it tends to be less reliable for dist-upgrading from one stable to the next. See my article apt-get, aptitude, … pick the right package manager for you.
Related videos on Youtube
Yejin
Updated on September 17, 2022Comments
-
Yejin over 1 year
Some time ago I read that
aptitude
is the preferred tool for installation on Debian-based systems. But when you search around on how to administer a Debian-based system, then aptitude is rarely mentioned. Most people seem to preferapt-get
- and that's even true for the Debian wiki pages!Thus I am wondering if I have missed something. Which is the right tool to use?
-
Admin over 11 yearsInterestingly Ubuntu no longer installs
aptitude
by default. -
Admin over 11 yearsThe single most important difference for me, is that after reading the docs thoroughly, I can find no way to get the source of a package via aptitude.
apt-get source package-name
will do it, but I've seen no aptitude equivalent -
Admin about 10 yearsOne thing is that
aptitude search package-name
works in aptitude. Another isaptitude why package-name
is also useful but not inapt-get
. I also thing that the command line ofaptitude
is a bit cleaned up compared toapt-get
. But as you noticed, there areaptitude build-dep package-name
but noaptitude source package-name
.
-
-
liori about 14 yearsIn addition to that, aptitude allows to browse through possible resolutions of conflicts easily, whereas with apt-get you usually have only one possible way shown and either you accept it or you have to do resolution by hand (f.e. using dpkg).
-
intuited almost 14 years
apt-get
does have the advantage of being more memory-efficient. This is unlikely to be noticeable for most users; I wasn't really aware of it until I tried to upgrade packages on a full Debian install with 32MB of RAM.aptitude
ended up thrashing in swap for about an hour per run; apt-get was significantly faster. -
Charles Stewart over 11 years@HubertKario - Yes, indeed. I've updated my answer.
-
EricR over 11 yearsSearch features are available from
apt-get
viaapt-cache search NAME
-
Cameron Mark Lewis over 10 yearsCitation needed, but that would be a compelling difference.
-
deizel. over 10 yearsCitation: debian-handbook.info/browse/stable/…
-
Legionair over 10 yearsActually
apt-get
does that as well, withapt-get autoremove <package-name>
. Bothapt-get
andaptitude
mark auto-installed packages -
Anders about 10 yearsBut
aptitude
do clean up auto packages each time it's used. Whileapt-get
you need to start that explicit. -
Totty.js almost 10 yearsI can only say that
apt-get
almost always throws errors (experience from Ubuntu server 12.10, 14.04) whileaptitude
can actually do something. I still don't understand how apt-get still exists. -
niceman about 9 years@EricR true but I didn't find search capabilities as these
-
andrybak almost 5 yearsThere is a new kid in school^W^W^W tool in our APT toolbox, namely
apt
. Should I ask a new question with "apt-get vs aptitude vs apt"?