Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

According to the manual, it

   search regex...
       search performs a full text search on all available package lists
       for the POSIX regex pattern given, see regex(7). It searches the
       package names and the descriptions for an occurrence of the regular
       expression and prints out the package name and the short
       description, including virtual package names. If --full is given
       then output identical to show is produced for each matched package,
       and if --names-only is given then the long description is not
       searched, only the package name is.

   --names-only, -n
       Only search on the package names, not the long descriptions.
       Configuration Item: APT::Cache::NamesOnly.

However, I came across a strange situation:

$ apt-cache search --names-only 'kde*' | grep tkcv
tkcvs - Graphical front-end to CVS and Subversion

Why in the world would the command above match tk8.6-doc? Braiam and I spent a few minutes chatting about this and he noticed that

$ apt-cache show tkcvs | grep -i kd
Replaces: tkdiff
Provides: tkdiff

So, Braiam suggested that it's matching the Replaces field as well which makes a certain amount of sense in the case of changing package names. OK then, but what about:

$ apt-cache search --names-only 'kde*' | grep tk8.6
tk8.6-doc - Tk toolkit for Tcl and X11, v8.6 - manual pages
$ apt-cache show tk8.6-doc | grep -i kd
Provides: tkdoc
Conflicts: tkdoc

Here it is either matching the Conflicts or the Provides fields and I can't twist the meaning of --names-only to make it match those fields. So, what exactly does --names-only search through? Is it the names of all packages that are mentioned in a package's description? It is clearly not matching the package name alone.

share|improve this question
If I have to guess it's matching the virtual package name, and since apt-cache doesn't handle well the virtual packages it shows you the one with higher version. – Braiam Mar 10 '14 at 3:50
up vote 5 down vote accepted

It turns out that apt-cache search --names-only also searches for Provides. The man page needs to be updated. Here is a link to the bug report regarding the same.

As per bug #98695¹, it seems that "apt-cache search --names-only" is also looking into "Provides" field while man page suggests that only package name is queried.

I think the manual page of apt-cache should be updated accordingly to reflect the current state of the paremeter.


This was the wishlist that caused the behavior of apt-cache search to be changed to search Provides in addition to the package name.

share|improve this answer
I think you've nailed it. Every case I can find seems to be matching against a Provides field. I'll give it a little while longer and come back and accept. Thanks! – terdon Mar 10 '14 at 4:10
@terdon You question prompted to hunt for this. I've myself wondered about the issue you reported a couple of times earlier, but didn't really chase it. – devnull Mar 10 '14 at 4:15

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.