An RPM package contains a set of files, typically compiled software binaries, libraries, and their development source files. These files are packaged in a cpio archive format, and finally wrapped in an RPM file along with any necessary package-specific metadata.
You can view the content of an RPM package with rpm or repoquery command.
If you want to extract files from an RPM package without installing it, here is how: first obtain a cpio archive from the RPM file, and then extract actual files from the cpio archive.
The following describes how to achieve this from the Linux command line.
Install Necessary Tools
First, install necessary command line tools.
On Ubuntu, Debian or Linux Mint:
On CentOS, Fedora or RHEL:
Extract Files from an RPM Package
Once the necessary tools are installed, proceed as follows. This will extract all files in foo.rpm into the current directory.
The rpm2cpio command extracts a cpio archive from an RPM file, and cpio command extract files from the cpio archive.
The options used with the cpio command are described as follows.
- -i: extract files
- -d: make directories
- -m: preserve modification time
- -v: verbose
Subscribe to Ask Xmodulo
Do you want to receive Linux related questions & answers published at Ask Xmodulo? Enter your email address below, and we will deliver our Linux Q&A straight to your email box, for free. Delivery powered by Google Feedburner.
Did you find this tutorial helpful? Then please be generous and support Xmodulo!