pkgfile
Find package providing a specific file
TLDR
Synchronize the pkgfile database
Search for a package that owns a specific file
List all files provided by a package
List executables provided by a package
Search for a package that owns a specific file using case-insensitive matching
Search for a package that owns a specific file in the bin or sbin directory
Search for a package that owns a specific file, displaying the package version
Search for a package that owns a specific file in a specific repository
SYNOPSIS
pkgfile [options] <file-pattern>
PARAMETERS
-u, --update
Updates the local pkgfile database from the configured repositories.
-s, --search
Searches for files matching the provided pattern (this is the default action if no other action is specified).
-l, --list
Lists the contents of specified packages. This option requires package names as arguments instead of file patterns.
-g, --glob
Interprets the file pattern as a glob expression (e.g., *.conf).
-r, --regex
Interprets the file pattern as a regular expression.
-i, --ignore-case
Performs a case-insensitive search.
-v, --verbose
Enables verbose output, showing more details about the search process.
-q, --quiet
Suppresses error messages.
-d
Specifies an alternative path for the pkgfile database.
-z
Searches only within files belonging to the specified repository. Can be used multiple times.
-e, --uninstalled
Also searches for files provided by packages that are not currently installed on the system.
-m
Further filters results by package name matching the given pattern (glob or regex depending on -g or -r).
-p, --package-name
Only prints the name of the package that owns the file, without the file path.
-c, --color
Forces colored output.
--help
Displays a help message and exits.
--version
Displays version information and exits.
DESCRIPTION
pkgfile is a command-line utility used to quickly determine which Arch Linux package provides a specified file or matches a given pattern. It works by querying a local database that contains a listing of all files shipped by packages in your configured repositories. This tool is invaluable for troubleshooting missing commands, identifying the source of configuration files, or simply discovering which package to install to get a particular file. It can search for exact filenames, glob patterns, or regular expressions, and its database can be updated to reflect the latest package changes in the repositories.
CAVEATS
pkgfile relies on a local database of package file lists. If this database is not regularly updated using pkgfile -u, search results may be outdated or incomplete, leading to inaccurate information about file ownership. This command is primarily designed for Arch Linux and other Pacman-based distributions; it is not available by default on Debian/Ubuntu or Fedora/RHEL systems, which have their own equivalent utilities (e.g., apt-file, dnf provides). The database can consume significant disk space.
DATABASE MANAGEMENT
The pkgfile database must be updated regularly to ensure accurate results. This is done using the command pkgfile -u. It's often recommended to run this command after a system update or new repository synchronization. The database is typically stored in /var/cache/pkgfile/.
COMMON USAGE EXAMPLES
- To find which package provides the ls command: pkgfile /usr/bin/ls
- To find all packages that contain files ending with .so: pkgfile -r '.*\.so$'
- To list all files within the bash package: pkgfile -l bash
- To search for files matching a glob pattern, e.g., all .conf files: pkgfile -g '*.conf'
HISTORY
pkgfile was developed specifically for the Arch Linux ecosystem to fill a gap in pacman's functionality: the ability to quickly determine which package provides a given file without having to download or install packages. It became a crucial tool for system administrators and users for troubleshooting and package management. It is often distributed as part of the pacman-contrib package, highlighting its supplementary role to the core pacman system. Its development has focused on efficiency and providing up-to-date file mappings.