Javascript required
Skip to content Skip to sidebar Skip to footer

How Can You Determine the Rpm Package That Owns a File?

Related Packages and Files

Sometimes you want to know the related parcel of a file, before installation, or when it is already in that location. This is of neat help during system hardening or general organisation cleanups. In this article we have a wait at several ways to determine the relationships between files and the bundle they belong to. We have gathered this information for multiple Linux distributions.

CentOS, Fedora, RHEL

Evidence files for RPM packages

rpm -qlp /path/to/file.rpm

Show files for packages on the repository

If you utilise dnf, then you lot can query files from the packages that are in your repositories. The package itself does not take to be installed.

dnf repoquery -q -l packagename

Apply the -q option with dnf to show simply the relevant output.

Query related packages from repository packages with DNF

Show files per installed parcel

To testify what files are in a parcel, use the rpm command.

rpm -ql parcel

If you have the file name, yous tin can turn this around and notice the related package.

rpm -qf /bin/ps

The output will provide the packet and its version.

Screenshot of querying a file and its related package with rpm tool

To simply see the package name, use the –queryformat selection.

rpm -qf /bin/ps --queryformat '%{NAME}'

Withyum you can practice a like request to see the related package.

yum whatprovides /bin/ps

And with DNF in that location is theprovides argument.

dnf provides /bin/ps

This will requite you possibly multiple hits, as a file tin can exist office of packages from different repositories.

Show related packages from installed file or binary with DNF

This information is less piece of cake to parse due to the different types of lines.

Debian and Ubuntu

Observe related package

If you want to find the related package of a binary (or file), we showtime have to know the total path. If you know the binary, then utilise the which control to discover where it is stored. Using the discover command is another option, but may be less efficient. With the dpkg package management tool nosotros tin can find the related packet.

dpkg -S /usr/sbin/atd | awk -F: '{impress $1}'

Without the awk control, the output volition look similar this.

Determine file and its related-package on Debian and Ubuntu

Evidence files installed by bundle

If you already know the package proper name, you tin speedily expect upwards the files that are installed by a Debian package.

dpkg -L bundle

Let'due south do the same for the at package and encounter what it exactly installs (and where).

Show files installed by a Debian package

Gentoo

The first selection is using equery, which is part of the packageapp-portage/gentoolkit.

equery files <installed packet>

The package itself should be installed.

Next alternative is qlist, which is part of app-portage/portage-utils

qlist <installed package>

OpenSUSE

Systems running the distributions from SuSE can use the zypper tool to find the link betwixt a file and a package.

Show related parcel

zypper what-provides /bin/ps

Got more useful commands to share? Allow information technology know in the comments and we add them to the article.

gaskblace1968.blogspot.com

Source: https://linux-audit.com/determine-file-and-related-package/