devutils/ATFQ/book ATFQ git

Part II · Your system

24.1 Which package owns a file

alsopackagepackageswhich packagepackage managerdpkg -srpm -qfpacman -qoowns

TL;DR

  • Every file a package installs is recorded in the package database: ask it who owns a file.
  • dpkg -S on Debian and Ubuntu, rpm -qf on Fedora and openSUSE, pacman -Qo on Arch.
  • For a program that isn't installed yet, search the repositories instead (see 23.2).
dpkg -S /usr/bin/curl
rpm -qf /usr/bin/curl
pacman -Qo /usr/bin/curl

On your machine

alice@laptopexample
$ atfq 24.1
  dpkg      2 packages
  Snap      2 snaps
  Flatpak   3 apps

An example: Alice's laptop, one of the test machines. In your terminal, this block shows your own machine, read live.

Pitfalls

Deep dive 2 questions

What's in the package database?

For each package: its version, its dependencies, and the list of its files with checksums. That's how dpkg --verify, rpm -V and pacman -Qkk can tell which installed files were changed since installation.

Why does it matter?

Before editing or deleting a file under /usr or /etc, knowing its package tells you whether an update will overwrite your change, or bring a deleted file back. Changes belong in your own files: a drop-in, a file in /etc, or /usr/local.

Commands
dpkg rpm pacman
See also
24.2 Native packages vs Snap and Flatpak
23.2 ELF and "command not found"