Most of the people know that how to extract tarballs or zip files but less people know about extracting an RPM (Redhat Package Manager). RPM packages are containers for the collection of files. Lots of time you would like to see the contents of the file instead of installing it (for example: you want the configuration files without installing the rpm). For that you would like to extract the file.

Extract RPM file:

To extract an RPM file there is no option available in RPM command. But there is a small utility availble called rpm2cpio and cpio. This utility extracts the cpio archive from RPM. rpm2cpio converts the .rpm file specified as a single argument to a cpio archive on standard out.

$ rpm2cpio compiz-0.0.13.rpm | cpio -idmv

Output:

./etc/gconf/schemas/compiz.schemas
./usr/bin/compiz
./usr/bin/desktop-effects
./usr/bin/gnome-window-decorator
./usr/lib64/compiz/libcube.so
….

……..

./usr/share/locale/zh_CN/LC_MESSAGES/compiz.mo
./usr/share/locale/zh_CN/LC_MESSAGES/desktop-effects.mo
./usr/share/locale/zh_TW/LC_MESSAGES/compiz.mo
./usr/share/locale/zh_TW/LC_MESSAGES/desktop-effects.mo
4228 blocks

If you just need to list the contents of the package without extracting them, use the following:

$ rpm2cpio compiz-0.0.13.rpm | cpio -vt

Output:

-rw-r–r– 1 root root 1166382 Jun 10 2008 ./etc/gconf/schemas/compiz.schemas
-rwxr-xr-x 1 root root 161592 Jun 10 2008 ./usr/bin/compiz
-rwxr-xr-x 1 root root 19928 Jun 10 2008 ./usr/bin/desktop-effects
-rwxr-xr-x 1 root root 74520 Jun 10 2008 ./usr/bin/gnome-window-decorator

……

………..
-rw-r–r– 1 root root 19134 Jun 10 2008 ./usr/share/locale/zh_CN/LC_MESSAGES/compiz.mo
-rw-r–r– 1 root root 1237 Jun 10 2008 ./usr/share/locale/zh_CN/LC_MESSAGES/desktop-effects.mo
-rw-r–r– 1 root root 19723 Jun 10 2008 ./usr/share/locale/zh_TW/LC_MESSAGES/compiz.mo
-rw-r–r– 1 root root 1298 Jun 10 2008 ./usr/share/locale/zh_TW/LC_MESSAGES/desktop-effects.mo
4228 blocks
Output of rpm2cpio piped to cpio command with following options:
  • i: Restore archive
  • d: Create leading directories where needed
  • m: Retain previous file modification times when creating files
  • v: Verbose i.e. display progress
  • t: Print a table of contents of the input
If you enjoyed this post, make sure you subscribe to my RSS feed!!!!

No related content found.