pkgfile - ArchWiki

# pkgfile

Related articles

- pacman

pkgfile is a tool for searching files from packages in the official repositories.

## Installation

Install pkgfile from the official repositories, or pkgfile-gitAUR from the AUR.

The pkgfile database can then be synced with:

    # pkgfile -u

## Usage

To search for a package that owns the file `makepkg`:

    $ pkgfile makepkg

    core/pacman

To list all files provided by archlinux-keyring:

    $ pkgfile -l archlinux-keyring

    core/archlinux-keyring usr/
    core/archlinux-keyring usr/share/
    core/archlinux-keyring usr/share/pacman/
    core/archlinux-keyring usr/share/pacman/keyrings/
    core/archlinux-keyring usr/share/pacman/keyrings/archlinux-revoked
    core/archlinux-keyring usr/share/pacman/keyrings/archlinux-trusted
    core/archlinux-keyring usr/share/pacman/keyrings/archlinux.gpg

Latter is comparable to `pacman -Ql` (see pacman#Querying package databases), except it applies to remote packages.

## Command not found

pkgfile includes a "command not found" hook for Bash and Zsh that will automatically search the official repositories, when entering an unrecognized command:

    $ abiword

    abiword may be found in the following packages:
      extra/abiword 2.8.6-7 usr/bin/abiword

To enable it in all children shells, you need to source the hook from one of your shell initialization files.

### Bash

    ~/.bashrc

    source /usr/share/doc/pkgfile/command-not-found.bash

### Zsh

    ~/.zshrc

    source /usr/share/doc/pkgfile/command-not-found.zsh

### Fish

pkgfile does not provide a hook specifically for Fish, but it is sufficient to define your own `command-not-found` function, which will be run when Fish encounters an unknown command:

    ~/.config/fish/functions/command-not-found.fish

    function command-not-found
            set cmd $argv[2]
            set pkgs (pkgfile -b -v $argv 2>/dev/null)
            if test -n $pkgs
                    echo "$cmd may be found in the following packages:"
                    echo "$pkgs"
                    return 0
            end
            return 127
    end

## Automatic updates

pkgfile ships with a systemd service and timer for automatically synchronizing the pkgfile database. To activate automatic updates enable `pkgfile-update.timer`.

By default, pkgfile will be updated daily. To change this schedule, copy `/usr/lib/systemd/system/pkgfile-update.timer` to `/etc/systemd/system/pkgfile-update.timer` and edit the latter file.

Categories:

- Package development
- Package management