original content:
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.
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 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 to 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- longform: [ aptitude search '?and(?name(firmware),?description(wireless))' ]
(note in shortform 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
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)
http://algebraicthunk.net/~dburrows/projects/aptitude/doc/en/ch02s03s05.html#tableSearchTermQuickGuide
aptitudeby default. – Mechanical snail Aug 16 '12 at 0:35apt-get source package-namewill do it, but I've seen no aptitude equivalent – EricR Sep 1 '12 at 7:10