rpm is a powerful Package Manager, which can be used to build, install, query, verify, update, and erase individual software packages. This is the first sentence in the long rpm manual that lacks examples. On the other hand, I will try to write nothing more but the rpm examples. Before examples, just to mention that RPM stands for the RedHat Package Manager. Enjoy!
# save and sort all installed packages to the /tmp/packages.txt file rpm -qa | sort > /tmp/packages.txt # list all files contained in rpm package "bash" ("bash" package is installed) rpm -ql bash # list all files in non installed "mplayer" package rpm -qlp /tmp/mplayer-1.0-0.103.20080903svn.fc10.i386.rpm # list package information ("bash" package is installed) rpm -qi bash # list package information ("mplayer" package is not installed) rpm -qip /tmp/mplayer-1.0-0.103.20080903svn.fc10.i386.rpm # list depended files of installed "bash" package rpm -qR bash # list depended files of not installed "mplayer" package rpm -qRp /tmp/mplayer-1.0-0.103.20080903svn.fc10.i386.rpm # how to install rpm package rpm -ivh /tmp/mplayer-1.0-0.103.20080903svn.fc10.i386.rpm # how to upgrade package rpm -Uvh /tmp/mplayer-1.0-0.103.20080903svn.fc10.i386.rpm # how to downgrade rpm packages (httpd 2.0.61 was installed) rpm -Uvh --oldpackage httpd-2.0.54-10.2.i386.rpm httpd-devel-2.0.54-10.2.i386.rpm # how to delete installed rpm package rpm -e sqlite-devel # compare information about the installed files with information stored in the rpm database rpm -V httpd # how to import rpm key rpm --import RPM-GPG-KEY.dag.txt # list all imported keys rpm -q gpg-pubkey --qf "%{summary} -> %{version}-%{release}\n"
If you want to unpack rpm package, you will have to use rpm2cpio and cpio commands. rpm2cpio extracts cpio archive from the rpm package. I will suggest you to run rpm2cpio inside empty temporary directory.
rpm2cpio gpsim-lcd-0.1.1-1.i386.rpm | cpio --extract --make-directories
Almost every file in RedHat family belongs to some rpm package. In few steps I will show you how to find a package that contains a particular file. Lets find the rpm package that contains “diff” command.
# first find the full path of the "diff" command bash> which diff /usr/bin/diff # now, with the full path, you can find the package bash> rpm -qf /usr/bin/diff diffutils-2.8.1-21.fc9.i386
Maybe the RPM file naming convention should be placed before examples, but it’s shouldn’t be omitted for sure. The convention is: name-version-release.architecture.rpm where:
- name is a name describing the packaged software
- version is the version of the packaged software
- release is the number of times this version of the software has been packaged
- architecture is a shorthand name describing the type of computer hardware the packaged software is meant to run on