Discovering which package installed a specific file on your Linux system is invaluable when you need to restore default configurations after unintended edits. In this guide, we’ll explore DNF-based commands to:Documentation Index
Fetch the complete documentation index at: https://notes.kodekloud.com/llms.txt
Use this file to discover all available pages before exploring further.
- Find the package providing a file or command
- List all files in a package
- Filter package file listings
These examples assume a DNF-based distribution (Fedora, RHEL, CentOS Stream). On older systems using
yum, substitute yum provides and yum repoquery.Table of Common DNF Queries
| Command | Purpose | Example | |
|---|---|---|---|
dnf provides <file> | Identify package owning a file | dnf provides /etc/anacrontab | |
dnf provides <command> | Find package that supplies a CLI command | dnf provides docker | |
dnf repoquery --list <pkg> | List every file in any package | dnf repoquery --list nginx | |
dnf repoquery --list <pkg> | grep <pattern> | Filter listed files by name or extension | `… | grep ‘.conf’` |
1. Find Which Package Owns a File
Suppose you’ve modified/etc/anacrontab and want to revert it to the distribution’s original version. Use:
cronie-anacron as the provider. To restore:
/etc/anacrontab is back in place.
Removing system files can affect service behavior. Always backup configurations before deletion.
2. Discover Which Package Supplies a Command
Want thedocker CLI but unsure which package includes it? Run:
podman-docker emulates the Docker CLI, so install it to use docker.
3. List All Files in a Package
To inspect every file a package ships—even if it isn’t installed locally—use:4. Filter the File Listing
Narrow down to specific file types (e.g., configuration files) by piping togrep: