RPM is the package manager format used on Fedora Core (it’s also widely used on others). It stands for Red Hat package Manager (well, who cares anyway). You probably already know you can install or uninstall RPMs, but you can do way more than that. RPM is the filename extension of individual packages you can install, but it’s also the name of the whole underlying system that keeps track of what’s installed on your computer, where and how. The
rpm command has lots of parameters and options. Here’s a couple of ones I use 99% of the time.
To install an
1 # rpm -Uvh file.rpm
-U as in update which permits the package manager to update to a newer version a program you already installed before. Don’t worry if the rpm file you install was never installed before, because if this is the case, then the package manager will behave as if you specified
-i instead of
-U, which means of course: install. So in short: always use
-U, never use
One exception is to be noted: kernels can be installed multiple times (in different versions), so always use
-i and not
-U when manually installing kernels.
-v are only to display stuff while rpm is working (by default it’s totally silent).
To list currently installed packages:
1 $ rpm -qa
-q as in query, which means that rpm has to just query its database, not installing or uninstalling anything.
-a means all packages.
For a faster version that doesn’t check signatures or compute digests, you can use:
1 $ rpm -qa --nodigest --nosignature
To list all the files installed by a specific package:
1 $ rpm -ql package_name
-l as in list files.
Note that you don’t have to type the version number of the package.
For example if with the previous installed packages listing command you had “bash-3.1-6.2”, you can only use “bash” here.
To check the consistency of an installed package:
1 $ rpm -V package_name
-V as in verify. If nothing is displayed, then everything is okay. Else, you will have one line per file-problem with a letter-code telling you what’s the problem (missing file, changed size, changed permissions, changed checksum, etc.). It’s detailed in the
To uninstall a package:
1 # rpm -e package_name
-e as in erase. Beware: it won’t ask you for confirmation.
To ask RPM to which package a given file belongs to:
1 $ rpm -qf /path/to/some/file
I find this one particularely great! To list the contents of an rpm file:
1 $ rpm -qlp filename.rpm
-p as in package. You can also use
-qlpv if you want more details.
Note the difference between
-qlp: the first is about an already installed package (you don’t even need to still have the rpm file you used to install it), the second is about an actual rpm file (installed or not).
Now, last but not least… how to extract the contents of an rpm file?
I mean, how extracting the contents of an rpm file without installing it at all? This can be useful if you just need one file stored in an rpm but don’t want to install the whole stuff. Well, this is pretty easy (once you know it!). Place yourself into an empty directory, and type:
1 $ rpm2cpio /path/to/somefile.rpm | cpio -idv
That’s all! The
cpio program is found in the RPM of the same name (just
yum install it if you don’t have it).