rpm

RPM package manager is used by large number of Linux distributions (Red Hat Enterprise, CentOS, Fedora). Like dpkg, rpm is meant to manage local software packages. This means it can only install, verify, remove, query packages that are already downloaded and have .rpm file extension. The .rpm file format looks like this:

packagename-3.1.1-M10-x86_64.rpm
  • rpmpackagename is the name of the package
  • 3.1.1-M10 is the version number
  • x86_64 is the architecture
  • .rpm indicates this file is rpm archive

Install packages

Install this package

# rpm -i packagename-3.1.1-M10-x86_64.rpm

Install, verbose for nicer display, process bar.

# rpm -ivh packagename-3.1.1-M10-x86_64.rpm

Install file, and ignore dependencies. You want to install dependencies later.

# rpm -ivh --nodeps packagename-3.1.1-M10-x86_64.rpm

Verify file with checksums

# rpm -vK packagename-3.1.1-M10-x86_64.rpm

Query packages

Query if the package is installed

# rpm -q firefox

Query list, find if this package is installed

# rpm -ql random.rpm

Query list and show detailed information about that package.

# rpm -qi bittorent

Query list of installed packages, sort by newest first

# rpm -qa --last
  • -q: Query a package and see if it is installed
  • -p: List dependencies
  • -R: List package’s dependencies
# rpm -qpR random.rpm
  • -qf: Query file
  • Find to which package this file belongs to.
# rpm -qf /usr/bin/htpasswd
  • qip: Query info package
  • We downloaded .rpm package, use this too find more information about it.
# rpm -qip random.rpm
  • Display manual pages related to vmstat package
  • qdf: Query document file
# rpm -qdf /usr/bin/vmstat

Find all configuration files used by this package

# rpm -qc openssh

Reverse to -qc, shows what package has this file

# rpm -q --whatprovides /usr/bin/zsh

Upgrade packages

  • Upgrade package.
  • Also, it will maintain backup of older package so that it can be reinstalled if error occurs.
# rpm -Uvh random.rpm

Upgrade this package, but only if newer version exists.

# rpm -F random.rpm

Verify packages

  • Vp: Verify package
  • Compare installed package against rpm database
# rpm -Vp random.rpm
  • Va: Verify all
  • Verify all installed packages against rpm databse
# rpm -Va 

To verify packages, import GPG key

# rpm --import /path/to/key

Print all imported GPG keys

# rpm -qa gpg-pubkey*

Verify package’s integrity, and check if all package files are present

# rpm -V packagename-3.1.1-M10-x86_64.rpm

Remove packages

Remove installed package

# rpm -e package

Remove the package, but leave its dependencies

# rpm -e --nodeps nginx

Leave a Reply