How to install, upgrade and remove packages with rpm

RPM stands for Red Hat Package Manager. Fedora, openSUSE or Mandrake are all rpm based packages.

Watch Free Movies

rpm is used for installing .rpm packages, displaying package info or uninstalling packages.

In this article I will show you how to use the rpm package manager to manage packages.

How to verify if a package is installed or not, with rpm -q

To list all the installed packages use rpm -qa | less.
rpm -q packagename shows you if your package is installed or not.
$ rpm -q zsh
zsh-4.3.17-1.fc16.x86_64

Note: When you need to check if a package is installed or not, use rpm -q package instead of rpm -qa | grep package because it is much faster (because rpm -qa querries all the packages) and much shorter to type.

How to install a .rpm package with rpm -i:

RPM checks if the files are suitable for your system, installs the package and updates the package database.

So, I will install nmap:
$ ls nmap*
nmap-5.51-1.fc16.x86_64.rpm
$ sudo rpm -i nmap*

If you want a nicer output, use rpm -ivh . -v is for verbose and -h displays hashes as the file is unpacked.

How to see which package does a file belong to with rpm -qf:

$ rpm -qf /etc/ssh/sshd_config
openssh-server-5.8p2-25.fc16.x86_64

How to find information about a package with rpm -qi

This is usefull if you want to find out a package version, for example:
To display the full package info use rpm -qi | less
You can also display package info from a .rpm package (before you install it) with rpm -qi package*.rpm.

$ rpm -qi openssh | grep Version
Version : 5.8p2

How to list all the files in a package with rpm -qpl

You can list all the packages in a .rpm file, before you install it.
$ rpm -qpl nmap-5.51-1.fc16.x86_64.rpm
/usr/bin/ncat
/usr/bin/ndiff
/usr/bin/nmap
/usr/bin/nping
/usr/share/doc/nmap-5.51
[...]

How to list dependencies of a package with rpm -qR:

This will display all the packages needed in order to install your application succesfully:

$ rpm -qRp nmap-5.51-1.fc16.x86_64.rpm
/usr/bin/python
libc.so.6()(64bit)
libc.so.6(GLIBC_2.2.5)(64bit)
[...]

How to upgrade a package with rpm -U:

When you upgrade a package, rpm uninstalls the old package and installs the new version. If you want to upgrade an uninstalled package, it will install it first.
You can also use the -h and -v arguments for a nicer output:

$ sudo rpm -Uvh nmap-5.51-1.fc16.x86_64.rpm
Preparing... ########################################### [100%]
1:nmap ########################################### [100%]

How to uninstall a package with rpm -e:

rpm -e will erase the package in your system.

$ sudo rpm -e nmap

Scroll to Top