Tag: package managers

How to find out which package contains a file

How to find out which package a file is in

Sometimes the name of the required utility does not coincide with the name of the package - this is especially the case when one package contains several programs. As a result, a problem arises - to find a package in which the required executable file or header file is present (if you received an error during compilation due to the absence of a specific file).

This article will help you by showing you how to search packages by filename. Moreover, for all packages at once - regardless of whether they are installed or not.

The pkgfile utility looks in the .files metadata generated by repo-add to get information about the files in the packages. By default, the specified target is assumed to be the filename and pkgfile will return packages containing that file. The repositories that pkgfile looks for are determined by those included in /etc/pacman.conf.

To install the program, run the command:

sudo pacman -S pkgfile

Update the saved metadata files.

sudo pkgfile --update

For example, I need to find out which package contains the file finger. Then I run the following command:

pkgfile finger

As you can see, pkgfile did a great job - the finger executable is in the netkit-bsd-finger package in the blackarch repository.

Using the -l, --list option, you can view the contents of any package:

pkgfile -l netkit-bsd-finger

The target is the package name, not the file name, and the contents of the specified package are returned. This allows the use of repo/package style syntax (eg, “core/pacman”) to limit the search range, but only when --list is used without the --glob or --regex options.

Matching heuristic

In --search mode and without the --regex or --glob option, pkgfile will try to match the supplied target as the exact filename. If the target contains a '/' character, then an attempt will be made to match the full path. With --regex and --glob search enabled, pkgfile will always match the full path.

In --list mode and without the --regex or --glob option, pkgfile will try to match the supplied target as the exact package name. If the target contains a '/' character, the text before the forward slash will be considered a repository and searches will be limited to that repository only.

All pkgfile options


pkgfile [options] target


  -l, --list              list contents of a package
  -s, --search            search for packages containing the target (default)
  -u, --update            update repo files lists

  -b, --binaries          return only files contained in a bin dir
  -d, --directories       match directories in searches
  -g, --glob              enable matching with glob characters
  -i, --ignorecase        use case insensitive matching
  -R, --repo <repo>       search a singular repo
  -r, --regex             enable matching with regular expressions

  -q, --quiet             output less when listing
  -v, --verbose           output more
  -w, --raw               disable output justification
  -0, --null              null terminate output

  -z, --compress[=type]   compress downloaded repos

  -C, --config <file>     use an alternate config (default: /etc/pacman.conf)
  -D, --cachedir <dir>    use an alternate cachedir (default: /var/cache/pkgfile)
  -h, --help              display this help and exit
  -V, --version           display the version and exit

See also How to view package information in Arch Linux (BlackArch, Manjaro).

How to view package information in Arch Linux (BlackArch, Manjaro)

For each package in the system, you can find out such information as: version number, description, developer site, dependencies, recommended dependencies, packages with which there is a conflict, size, etc.

The commands described in this post work the same in Arch Linux, as well as all distributions based on it, such as BlackArch, Manjaro and others.

If you are interested in very brief information about the package - description, version number, and whether the package is installed, then you can use a command like this:


To display all available information about a package, use a command like:


To view information about a package installed from the AUR, use a command like:


For pikaur see the detailed article “Automatic installation and update of AUR packages”.

In addition to the usual information such as version, description, site address, dependencies, and more, the pikaur command will also show information typical of the AUR: ratings, popularity, when it was first presented, and so on.

So, using the -Si option and pacman or pikaur commands, you can display information about any package.

How to completely uninstall a package along with dependencies on Arch Linux (as well as BlackArch and Manjaro)

This tutorial uses pacman as the package management (uninstallation) program, but you can also use pikaur or yay instead, since the options discussed are the same for all these package managers.

Related: Automatic installation and update of AUR packages

A typical command to uninstall a program that will remove all package files:

sudo pacman -R PACKAGE

Indeed it will remove the specified package, but the configuration files of the package will remain, which will be renamed - the .pacsave extension has been added, and the dependencies that were installed for this package will remain.

To completely remove the program along with all its dependencies and without saving the configuration files, use a command like this:

sudo pacman -Rscun PACKAGE

This command uses the following options:

-c, --cascade

Remove all target packages, as well as all packages that depend on one or more target packages. This operation is recursive and must be used with caution as it can remove many potentially needed packages.

-n, --nosave

Instructs pacman to ignore backup configuration files. Usually, when a package is removed from the system, the database checks whether the configuration file should be renamed (the .pacsave extension is appended to it). When using this option, this does not happen - the configuration files are completely deleted.

-s, --recursive

Removes every specified target, including all its dependencies, provided that: (A) they are not required by other packages; and (B) they were not explicitly installed by the user. This operation is recursive and similar to the reverse --sync operation, and it helps to keep the system clean without orphans. If you want to skip condition (B), write the option twice.

-u, --unneeded

Removes targets that are not required by other packages. This is mostly useful when removing a group without using the -c option to avoid breaking any dependencies.