Identifying RPM files with the file(1) command

The magic file on most UNIX-like systems today should have the necessary information to identify RPM files. But in case your system doesn't, the following information can be added to the file:

#-------------------------------------------------------------------
#
# RPM: file(1) magic for Red Hat Packages
#
0       beshort         0xedab          
>2      beshort         0xeedb          RPM
>>4     byte            x               v%d
>>6     beshort         0               bin
>>6     beshort         1               src
>>8     beshort         1               i386
>>8     beshort         2               Alpha
>>8     beshort         3               Sparc
>>8     beshort         4               MIPS
>>8     beshort         5               PowerPC
>>8     beshort         6               68000
>>8     beshort         7               SGI
>>10    string          x               %s
      

The output of the file command is succinct:

# file baz
baz: RPM v3 bin i386 vlock-1.0-2
#
      

In this case, the file called baz is a version 3 format RPM file containing release 2 of version 1.0 of the vlock package, which has been built for the Intel x86 architecture.