Product SiteDocumentation Site

2.3.2. Other RPM commands

In addition to rpm, the RPM system includes a few more commands, including rpmbuild and rpm2cpio.
The rpmbuild command helps build RPM packages. Its usage is discussed in depth in Part II of this book.
The rpm2cpio command exports an RPM package file into the format that the cpio command expects. The cpio command works with many tape-backup packages. You can also take advantage of the fact that cpio can list the individual files in a cpio archive or extract files. To list the files in an RPM package, use a command like the following:
rpm2cpio package_file.rpm | cpio –t
For example, the following command lists all the files in the mlocate package:
rpm2cpio mlocate-0.22.2-2.i686.rpm | cpio –t
To display:
 ./etc/cron.daily/mlocate.cron ./etc/updatedb.conf ./usr/bin/locate ./usr/bin/updatedb ./usr/share/doc/mlocate-0.22.2 ./usr/share/doc/mlocate-0.22.2/AUTHORS ./usr/share/doc/mlocate-0.22.2/COPYING ./usr/share/doc/mlocate-0.22.2/NEWS ./usr/share/doc/mlocate-0.22.2/README ./usr/share/locale/bg/LC_MESSAGES/ ./usr/share/locale/ca/LC_MESSAGES/ ./usr/share/locale/cs/LC_MESSAGES/ ./usr/share/locale/da/LC_MESSAGES/ ./usr/share/locale/de/LC_MESSAGES/ ./usr/share/locale/es/LC_MESSAGES/ ./usr/share/locale/fr/LC_MESSAGES/ ./usr/share/locale/hu/LC_MESSAGES/ ./usr/share/locale/it/LC_MESSAGES/ ./usr/share/locale/ja/LC_MESSAGES/ ./usr/share/locale/ms/LC_MESSAGES/ ./usr/share/locale/nl/LC_MESSAGES/ ./usr/share/locale/pl/LC_MESSAGES/ ./usr/share/locale/pt/LC_MESSAGES/ ./usr/share/locale/pt_BR/LC_MESSAGES/ ./usr/share/locale/sr/LC_MESSAGES/ ./usr/share/locale/sr@latin/LC_MESSAGES/ ./usr/share/locale/sv/LC_MESSAGES/ ./usr/share/locale/zh_CN/LC_MESSAGES/ ./usr/share/man/man1/locate.1.gz ./usr/share/man/man5/mlocate.db.5.gz ./usr/share/man/man5/updatedb.conf.5.gz ./usr/share/man/man8/updatedb.8.gz ./var/lib/mlocate 555 blocks 
The rpm2cpio command can also help if you want to extract a single file from the RPM package, using the cpio –ivd command-line options, as follows:
 rpm2cpio mlocate-0.22.2-2.i686.rpm | cpio –ivd usr/share/doc/mlocate-0.22.2/README
This command will output local usr/share/doc/mlocate-0.22.2/README subdirectories and the README file located under usr/share/doc/mlocate-0.22.2.
The –i option tells cpio to extract files. The –d option tells cpio to make any local subdirectories as needed (usr/share/doc/mlocate-0.22.2, in this example), and the –v option asks cpio to politely output verbose messages about what it does. Of course, verbose is in the eye of the beholder; with many Unix and Linux commands, verbose output is still somewhat terse.