How to Use rpm2cpio Command in Linux

The rpm2cpio command converts RPM files into CPIO (CPIO comes from the phrase “copy in and out”) data streams. These streams can then be piped into the cpio command, which can extrapolate the files and directories.

Example:

# ls libgcc-4.8.5-4.el7.x86_64.rpm
# rpm2cpio libgcc-4.8.5-4.el7.x86_64.rpm | cpio -idum
353 blocks
# ls
lib64 libgcc-4.8.5-4.el7.x86_64.rpm usr
# ls usr/share/doc/libgcc-4.8.5 
COPYING COPYING3 COPYING3.LIB COPYING.LIB COPYING.RUNTIME

This process is useful to extract specific files from an RPM file without having to reinstall the entire RPM. The resulting files are exactly the files that were installed; however, they are placed in the current directory.

There are no options or arguments for the rpm2cpio command.

Related Post