cpio/rpm2cpio commands

To extract a cpio file:
$ cpio -iv < cpio_file

To list the contents of a cpio file:
$ cpio -itv < cpio_file

To create a cpio file with all files in the current directory:
$ ls | cpio -o > cpio_file

To extract all files from an RPM:
$ rpm2cpio RPM_file | cpio -idv

To extract individual file(s) from an RPM:
$ rpm2cpio RPM_file | cpio -id individual_file(s)

e.g. Extracting libcrypto.so.0.9.7a and libssl.so.0.9.7a from openssl-0.9.7a-2.i386.rpm:
$ rpm2cpio openssl-0.9.7a-2.i386.rpm | cpio -it egrep "libcrypto.so.0.9.7a|libssl.so.0.9.7a"

-rwxr-xr-x   1 root     root       992092 Feb 27 12:10 ./lib/libcrypto.so.0.9.7a
-rwxr-xr-x   1 root     root       216004 Feb 27 12:10 ./lib/libssl.so.0.9.7a

$ rpm2cpio openssl-0.9.7a-2.i386.rpm | cpio -idv ./lib/libssl.so.0.9.7a ./lib/libcrypto.so.0.9.7a

This will extract the two files from the RPM into a ./lib subdirectory.


To extract individual files from a Sun Flash Archive file:

1. Split the Flash Archive into the cookie, identification, and archive files.
$ flar split Flash_Archive_file

2. Extract the file(s) from the cpio archive.
e.g. extracting var/sadm/install/contents
$ cpio -idv var/sadm/install/contents < archive

Back to brandonhutchinson.com.

Last modified: 2007/01/12