Debian – apt-file vs apt-cache

aptdebian

I've known about apt-cache for quite some time, but only yesterday stumbled on apt-file.

My question is, given this kind of output from the two…

ttsiod@avalon ~
$ apt-cache search setxkb
x11-xkb-utils - X11 XKB utilities
xfce4-xkb-plugin - xkb layout switch plugin for the Xfce4 panel

ttsiod@avalon ~
$ apt-file find setxkb
fish: /usr/share/fish/completions/setxkbmap.fish
fish: /usr/share/fish/functions/__fish_complete_setxkbmap.fish
x11-xkb-utils: /usr/bin/setxkbmap
x11-xkb-utils: /usr/share/man/man1/setxkbmap.1.gz
xmanpages-ja: /usr/share/man/ja/man1/setxkbmap.1.gz
zsh: /usr/share/zsh/functions/Completion/X/_setxkbmap
zsh-beta: /usr/share/zsh-beta/functions/Completion/X/_setxkbmap
zsh-common: /usr/share/zsh/functions/Completion/X/_setxkbmap

…why would one bother with apt-cache? Isn't apt-file superior in every way?

I am probably missing something.

EDIT: The reason I am asking is because apt-file reported MORE packages than apt-cache. I only use apt-cache for the use case "I need tool/manpage/whatever named foo – which packages contain foo?" and it seems that apt-file seems to do everything apt-cache does, but better – it reports more packages (apt-cache MISSES some), and it also shows the filenames involved.

Best Answer

apt-cache queries a database of available packages and their metadata (installation source, version, dependencies, description, etc.).

apt-file queries a database of available packages and the files they contain.

The only information in common between these databases is that they both list available package names.

Related Question