How to Extract the Contents of an RPM File

Sometimes it can be useful to extract the contents of a RPM file without actually installing it. In order to do so, use the following command:

rpm2cpio file.rpm | cpio -idmv

This will extract the rpm into whatever directory you are in, including all of it's sub-directories. So for example, if you change directory into / and run the command above the rpm will be extracted and files/directories placed just as if you had installed the rpm. Normally first you would want to create and change into a working directory.