Sometime we need know on Ubuntu Machine about source or owner of file or command. We need to know through which package we installed that make available this command r file, that is sometime quit important when we need to same command that install on other machine and we need to source package to install it on other machine.
In RHEL/CentOS machine, we have a option in Yum what-provides that work in same way thay provide access to database for all possible file in configured repository.In same we also need to know some command in Ubuntu machine. let’s take some example and understand this case.

SetUP

I am using two Ubuntu machine for this demonstration. One is my laptop and another is newly purchased DELL Tower machine. Both machines has same Ubuntu 18.04.

So laptop Os is quit old and well configured for many purpose, so while setup OS hardware with same OS is always have some advantages. While doing it many times we used to know commands source packages which also required on this new machine.

Ubuntu Machine

Like this i am using sensors command to know machine components temperature while working on it. So i need to install same command to new machine

ssirohi@jarvis:~$ which sensors                   
/usr/bin/sensors                                  
ssirohi@jarvis:~$ apt-file search /usr/bin/sensors
lm-sensors: /usr/bin/sensors                      
lm-sensors: /usr/bin/sensors-conf-convert         

But before it we need to install same command and update its database with below command

ssirohi@srv2:~$ sudo apt-get install apt-file

In above we install apt-file packages which will install apt-file in Ubuntu machine. But we also need to update its database like below.

ssirohi@srv2:~$ sudo apt-file update

So now we know which is source package for sensors command, we can install it on new machine to get machine component.

RHEL/CentOS Machines

In case of of RHEL or CentOS Machine we have yum and rom command that provides options for it.

like in case if we need to package ownership of any system file or any command file.

# rpm -qf /etc/passwd 
setup-2.8.71-11.el7.noarch              

In above command we tried to know source package of /etc/passwd file, which is sourced through setup-2.8.71-11.el7.noarch

But if we need to some command of file, in that case we have one option in Yum command like below. This options is also accept regex, so we can filter or target specfic files for it

# yum whatprovides *bin/pcs
Loaded plugins: fastestmirror                                     
Loading mirror speeds from cached hostfile                        
 * base: mirror.ox.ac.uk                                          
 * epel: mirrors.coreix.net                                       
 * extras: mirror.ox.ac.uk                                        
 * updates: mirror.ox.ac.uk                                       
base/7/x86_64/filelists_db                                        
pcs-0.9.168-4.el7.centos.x86_64 : Pacemaker Configuration System  
Repo        : base                                                
Matched from:                                                     
Filename    : /usr/sbin/pcs