44

I've RPM file of which I want to examine its file contents. For .deb packages, I can use dpkg -x file.deb to extract it.

What is the equivalent command for a .rpm file? I'm looking for a command-line application.

Lekensteyn
  • 178,864

4 Answers4

61

file-roller seems to open rpm files. Alternatively you can use the command:

$ sudo apt-get install rpm2cpio
$ rpm2cpio /path/to/file.rpm | cpio -i --make-directories

that will extract the rpm content to the current directory.

malat
  • 471
enzotib
  • 96,253
  • Thanks, I just came across it: rpm2cpio file.rpm | cpio --extract --make-directories – Lekensteyn Jul 07 '11 at 20:57
  • On my Ubuntu system, my MATE app (Engrampa) first failed with "Unrecognized file format", but after installing rpm2cpio as suggested as alternative here, also the app now can read the RPM file. Perfect, thanks! – thutt Sep 15 '21 at 07:38
7

Install 7z:

apt install p7zip-full

and extract:

7z x /path/to/file.rpm 
7z x /path/to/file.cpio -o/path/to/extract/folder/
  • Unfortunately 7z is not aware of file permissions and for rpm packages which contain executables (i.e. most of them) this can be a problem. – Wug Oct 21 '19 at 19:57
  • @Wug to overcome the limitations of 7z: after the first step you can extract the file.cpio using (cd /path/to/extract/folder/ ; cpio -i -d </path/to/file.cpio). – pabouk - Ukraine stay strong Jun 21 '21 at 08:37
5

As far as I remember you have to use a app called alien which transforms .rpm to deb files. Use a terminal to do :

sudo apt-get install alien

then

sudo alien -d nameofyourpackage.rpm (-d for Debian package)

If you then need to examine it you can resort to your dpkg -x file.deb method

andybleaden
  • 1,903
3

You can also use alien to only extract the files (which it calls "generate a build tree")

alien --scripts --generate <package.rpm>

You will get 2 dirs - <package>, and <package>.orig, which is the raw extraction from the rpm.

Randall
  • 356