Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm interested in unpacking an rpm so I can get at the files without having to go through the install process. There don't seem to be any options for this using either the yum or rpm commands. My goal is to then modify and then rebuild the rpm. Is there a way to do this?

share|improve this question
up vote 3 down vote accepted

you could unpack rpm using command

rpm2cpio package.rpm | cpio -i --make-directories

If you want to modify package, the better way is to download package.src.rpm file, install it using rpm -i package.src.rpm. This would place sources to /usr/src/redhat/SOURCES. You could patch sources and modify spec file located in /usr/src/redhat/SPECS/ and then rebuild package using

rpmbuild -bb /usr/src/redhat/SPECS/package.spec
share|improve this answer
I don't file /usr/src/redhat – M.Rezaei Oct 28 '09 at 9:48
yumdownloader (in yum-utils package) is handy for snagging srpms. – Chad Huneycutt Oct 28 '09 at 14:19
the directory /usr/src/redhat should be created, when you install your first source rpm. – sumar Oct 30 '09 at 10:04

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.