1) How to search for packages matching "word1 or word2" with aptitude?
2) How to search for packages matching "word1 and word2" with aptitude?
This wasn't clear to me from the documentation initially either. In my case, I wanted to search for packages that matched a name and were installed.
Anyway, the key is that each argument is a space separated list of conditions that are AND'd, and each argument is OR'd. So:
$ aptitude search "foo bar"
Will search for all packages that contain the string foo
and the string bar
Where as:
$ aptitude search foo bar
Will search for all packages which contain either foo
or bar
You can then combine this with other conditions that aptitude accepts to do things like:
$ aptitude search "~i python"
Will list all installed packages that contain the string python
in their name
There are also other ways of doing this. For example:
$ aptitude search "?and(foo, bar)"
$ aptitude search "?or(foo, bar)"