HOWTO: Extracting RPM from command line

Sometimes, admins might want to extract some files from a RPM file for some purposes. If on a system with GUI, this can be easily done using file-roller or some other GUI based archive manager that supports RPM/CPIO archives. RPMs are basically modified CPIO archives, so we use rpm2cpio and cpio command to extract files from it in a CLI environment.

List out contained files
rpm2cpio <rpmpackage.rpm> |cpio -t

Extract all files
rpm2cpio <rpmpackage.rpm> |cpio -id

Extract specific file
rpm2cpio <rpmpackage.rpm> |cpio -id <file>
Note: extracting specific files requires you to put the full path of the file in the archive which you get from the cpio -t output.

You can read more about using cpio from the manpages and from this site

Comments

Popular posts from this blog

Tee'ing Python subprocess.Popen output

Consolidated community site infrastructure on Plone

HOWTO: Linux Container (LXC) on Fedora 12