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 -Son Debian and Ubuntu,rpm -qfon Fedora and openSUSE,pacman -Qoon 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
$ 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
- Give the full path:
dpkg -S curlmatches every path that contains "curl".command -v curlgives the path. - Files you created, and settings a package generated after install, belong to no package.
- With merged /usr (see 13.1), ask about
/usr/bin/…rather than/bin/…: the database may only know one of the two.
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.