Last updated on August 5, 2020 by Dan Nanni
foo.rpm) from somewhere, and I would like to manually extract files from the RPM package. Is there an easy way to extract files from an RPM package without installing it?
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
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
The following describes how to achieve this from the Linux command line.
First, install necessary command line tools.
$ sudo apt-get install rpm2cpio
$ sudo yum install rpm
Once the necessary tools are installed, proceed as follows. This will extract all files in
foo.rpm into the current directory.
$ rpm2cpio foo.rpm | cpio -idmv
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