Find which package contains /usr/bin/example-tool.
Include packages that are not currently installed.
Which command is appropriate?
apt-file search queries repository Contents indexes by path, so it can find providers even when the package is not installed.
Detailed explanation
apt-file list /usr/bin/example-toolIncorrect. apt-file list starts with a package name and lists its paths.
apt-file search /usr/bin/example-toolCorrect. apt-file search /usr/bin/example-tool finds packages providing the path.
Correct. apt-file search reverses a path into its providing package.
apt-cache depends /usr/bin/example-toolIncorrect. apt-cache depends handles package relationships, not file providers.
Incorrect. depends displays package relationships.
apt show /usr/bin/example-toolIncorrect. apt show expects a package name and does not reverse-lookup a path.
Incorrect. show displays metadata for a package name.
Try it yourself
An example you can run in a temporary verification environment.
apt-file search /usr/bin/example-toolExpected result
該当すれば「パッケージ名: パス」の形式。apt-fileとContents索引が必要Key points
- search reverses path to package
- It can find uninstalled packages
- Contents indexes are used
Notes
- Environment: apt-file 3.x / 索引更新済み環境
- Use a disposable environment or simulation before package changes.
- APT behavior can vary with repository configuration and package-manager version.
Foundation review
Place the operation
Repository Contents data can answer a provider question before the package is installed; local package records cannot.
Check the side effect
Search a known path in the Contents index and compare it with a locally installed-file query.