Some times it’s require to find which package/application provide a command or a file or even a directory in Redhat based machines. yum/rpm commands will come to your rescue to find that.
Scenario: Recently we tried to install a command on a different 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.
Redhat provids options with yum and rpm commands to check for the package name if we give file name to these commands.
Finding package name which install a particular file in the machine by using yum command.
Syntax:
yum provides /path/to/your/file
Example: For example I want to find which package provides script command in Linux?
yum provides /usr/bin/script
Output:
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
* base: centos.aol.in
* extras: centos.aol.in
* updates: centos.aol.in
util-linux-ng-2.17.2-12.9.el6.i686 : A collection of basic system utilities
Repo : base
Matched from:
Filename : /usr/bin/script
util-linux-ng-2.17.2-12.4.el6.i686 : A collection of basic system utilities
Repo : installed
Matched from:
Other : Provides-match: /usr/bin/script
Finding package name which install a particular file in the machine by using rpm command.
Syntax:
rpm -qf /path/to/your/file
Example: For example I want to find which package provides script command in Linux?
rpm -qf /usr/bin/script
Output:
util-linux-ng-2.17.2-12.4.el6.i686
This will come handy when dealing with installing new packages.
Example: I want to check what package is responsible for installing /etc/init.d folder in Linux
rpm -qf /etc/init.d
Output:
chkconfig-1.3.47-1.el6.i686
Make a note that -q for query and -f for mention file. And everything in Linux is treated as file which include directory file as well. Know more about different file types available in Linux.
Stay tuned to more updates.
Latest posts by Surendra Anne (see all)
- Docker: How to copy files to/from docker container - June 30, 2020
- Anisble: ERROR! unexpected parameter type in action:
Fix - June 29, 2020 - FREE: JOIN OUR DEVOPS TELEGRAM GROUPS - August 2, 2019
- Review: Whizlabs Practice Tests for AWS Certified Solutions Architect Professional (CSAP) - August 27, 2018
- How to use ohai/chef-shell to get node attributes - July 19, 2018