How to find which out which package installed a file on Redhat and Debian/Ubuntu

Sometime you need to find out which package installed a particular file on your system. This may be because you need to reinstall the package or because you need to mirror the set-up on one system on another machine.

Linux Quick Tip - Package Management

Luckily its is easy to find out which package you need to install on rpm and dpkg based system. For Redhat based system you can run:

rpm -qf /path/to/file

or Debian/Ubuntu systems you can run

dpkg -S /path/to/file