How to Recreate/rebuild a RPM from installed files?

Many times we encounter situations where we want to replicate one package installation on a different machine but the actual RPM file no longer available. This happens mainly when you use yum to install packages. When you try to install same package on a different machine after few months, you might not get the same version of the software from yum repos. In this article we will explain how to recreate/rebuild an RPM from installed files using rpmrebuild

Recreate/rebuild a RPM from installed files using RPMREBUILD

Rpmrebuild is a 3rd party script you can use to do a re-packaging of an already installed RPM.

excerpts from the official page

“rpmrebuild is a tool to build an RPM file from a package that has already been installed in a basic use, rpmrebuild use does not require any rpm building knowledge. (On debian, the equivalent product is dpkg-repack).”

How to install rpmrebuild on centos ?

On a Centos machine you can install rpmrebuild using yum 


We have installed rpmrebuild package successfully

Creating first RPM file using rpmrebuild

First find the rpm package which we need to rebuild

Run rpmrebuild

From the above example, you can see that rpmrebuild created a new rpm file  and stored at “/root/rpmbuild/RPMS/x86_64/nginx-1.10.2-1.el6.x86_64.rpm” .

We can copy this to any other machine and use it to install same package on that machine.

You can find more details on their official page 


Leave a Reply

Your email address will not be published. Required fields are marked *