Linux / Unix Tips and Tricks

This blog contains Linux / Unix Tips and Tricks, collected during my work as a Unix System Administrator.
They are here for my own reference, but they might help you as well !

Linux: How to extract a single file from a RPM package

len | 12 December, 2008 12:20

I once got myself in the situation where I had no option but to retrieve a missing file from a rpm package. I didn't want to install the whole rpm, but only extract the missing file. Here's an example how to extract the original httpd.conf from the httpd package:

  1. Copy the rpm to your /tmp directory:

    $ cp httpd-2.2.8-3.i386.rpm /tmp
    $ cd /tmp
     
  2. Get the absolute filename from the rpm:

    $ rpm -qlp httpd-2.2.8-3.i386.rpm | grep httpd.conf
    /etc/httpd/conf/httpd.conf
     
  3. Extract the httpd.conf file from the rpm package:

    $ rpm2cpio httpd-2.2.8-3.i386.rpm | cpio -id ./etc/httpd/conf/httpd.conf
    4838 blocks
     
  4. The requested file is now extracted in the /tmp directory:

    $ ls -l /tmp/etc/httpd/conf/httpd.conf
    -rw-r--r-- 1 root root 33692 2008-12-12 12:41 /tmp/etc/httpd/conf/httpd.conf
     
 
Accessible and Valid XHTML 1.0 Strict and CSS
Powered by LifeType - Design by BalearWeb