Howto know which package provides a command or a file in RPM Linux systems
In this mini post, I’ll show you how to find which package/application provides a command or a file or even a directory in RPM Linux family “Redhat / CentOS / Scientific Linux releases 7 / 6 / 5”. We will use both yum and rpm to find the package which our command or file belongs to.
Recently we tried to install a command on a CentOS Linux machine which is already installed in one of our machines but not sure which package provides that command. If we find which package provide that package, that will save us not to install unnecessary packages in the process of installing this command.
Hints: 1. To be a good Sysadmin, always install only the needed packages on your Linux machines. 2. Installing unneeded packages on your Linux machines will badly affect your system as follow: # Your system will take much space on your disks and takes a longer time to update. # It may prone your system to different kinds of security threads. So, only install the minimum needed packages on your systems
Redhat/CentOS provides options with yum and rpm commands to check for the package name if we give file name to these commands.
So, we will use both yum and rpm package managers to fined our package we need to install.
- Method 1 : Using yum command to find our package.
Syntax: # yum provides command_name OR # yum provides /path/to/your/file
Here’s an example to find the package contains this command “lsb_release“, run the following commands:
# yum provides lsb_release Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: centos.mirror.xtratelecom.es * elrepo: mirrors.evowise.com * epel: mirror.uv.es * extras: centos.mirror.xtratelecom.es * nux-dextop: li.nux.ro * updates: centos.mirror.xtratelecom.es redhat-lsb-core-4.1-27.el7.centos.1.i686 : LSB Core module support Repo : base Matched from: Filename : /usr/bin/lsb_release redhat-lsb-core-4.1-27.el7.centos.1.x86_64 : LSB Core module support Repo : base Matched from: Filename : /usr/bin/lsb_release redhat-lsb-core-4.1-27.el7.centos.1.x86_64 : LSB Core module support Repo : @base Matched from: Filename : /bin/lsb_release redhat-lsb-core-4.1-27.el7.centos.1.x86_64 : LSB Core module support Repo : @base Matched from: Filename : /usr/bin/lsb_release
OR
# yum provides /usr/bin/lsb_release Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: centos.mirror.xtratelecom.es * elrepo: mirrors.evowise.com * epel: mirror.uv.es * extras: centos.mirror.xtratelecom.es * nux-dextop: li.nux.ro * updates: centos.mirror.xtratelecom.es redhat-lsb-core-4.1-27.el7.centos.1.i686 : LSB Core module support Repo : base Matched from: Filename : /usr/bin/lsb_release redhat-lsb-core-4.1-27.el7.centos.1.x86_64 : LSB Core module support Repo : base Matched from: Filename : /usr/bin/lsb_release redhat-lsb-core-4.1-27.el7.centos.1.x86_64 : LSB Core module support Repo : @base Matched from: Filename : /usr/bin/lsb_release
- Method 2 : Using rpm command to find our package.
Syntax:
# rpm -qf /path/to/your/file
Here’s an example to find the package contains this command “lsb_release“, run the following commands:
# rpm -qf /usr/bin/lsb_release redhat-lsb-core-4.1-27.el7.centos.1.x86_64
Now, we will search for the package provides this directory “/etc/init.d“, everything in Linux is treated as file which include directory file as well. We will use both yum and rpm to find the package contains this directory as follow:
- Using yum.
# yum provides /etc/init.d Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: centos.mirror.xtratelecom.es * elrepo: mirrors.evowise.com * epel: mirror.uv.es * extras: centos.mirror.xtratelecom.es * nux-dextop: li.nux.ro * updates: centos.mirror.xtratelecom.es chkconfig-1.3.61-5.el7.x86_64 : A system tool for maintaining the /etc/rc*.d hierarchy Repo : base Matched from: Filename : /etc/init.d chkconfig-1.3.61-5.el7_2.1.x86_64 : A system tool for maintaining the /etc/rc*.d hierarchy Repo : updates Matched from: Filename : /etc/init.d chkconfig-1.3.61-5.el7_2.1.x86_64 : A system tool for maintaining the /etc/rc*.d hierarchy Repo : @updates Matched from: Filename : /etc/init.d
- Using rpm.
# rpm -qf /etc/init.d chkconfig-1.3.61-5.el7_2.1.x86_64
Hints: 1. We used command provides with yum.2. We used options -q for query and -f for mention file with rpm. 2. Take care when using yum to install the correct package arch according to your system arch i.e choose either 32 bit or 64 bit package.
Finally, before we end this mini post, I need to mention the use of the command “lsb_release“.
lsb_release gives you a details about your system release and distribution as follow:
# lsb_release -a LSB Version: :core-4.1-amd64:core-4.1-noarch:cxx-4.1-amd64:cxx-4.1-noarch:desktop-4.1-amd64:desktop-4.1-noarch:languages-4.1-amd64:languages-4.1-noarch:printing-4.1-amd64:printing-4.1-noarch Distributor ID: CentOS Description: CentOS Linux release 7.2.1511 (Core) Release: 7.2.1511 Codename: Core
Here’s we use CentOS Linux system release 7.
If You Appreciate What We Do Here On Mimastech, You Should Consider:
- Stay Connected to: Facebook | Twitter | Google+
- Support us via PayPal Donation
- Subscribe to our email newsletters.
- Tell other sysadmins / friends about Us - Share and Like our posts and services
We are thankful for your never ending support.