Main Contents

RPM cheat sheet

November 20, 2009

The worst thing about commercial Linux is RPM. I can never remember the command line incantations required for even fairly simple tasks.

While yum eventually takes away the pain of applying software updates–so long as you’re not in a hurry–there are all kinds of other tasks it doesn’t handle. I therefore rely on an RPM cheat sheet I’ve assembled over the years. Here’s a copy for anyone else who might find it useful.

RPM cheat sheet
rpm -e package-1.2.3-gm Erase named package from system
rpm -i package-1.2.3-gm.rpm Install package file into system
rpm -U package-1.2.3-gm Upgrade package
rpm -F package1 package2 Upgrade packages to latest versions in an appropriate order
rpm -Fvh * Upgrade a bunch of packages from the matching RPM files
rpm -q package Returns full name and version of installed package
rpm -qp package.rpm Same for a non-installed package
rpm -qi package Returns misc details about package
rpm -qpi package.rpm Same for a non-installed package
rpm -qa | grep something Search all installed packages for something
rpm -qf file Which package put this file here?
rpm -ql package List of files in an installed package
rpm -qlp package.rpm Same for files in a non-installed package
rpm -qRl package List dependencies of an installed package
rpm -qR package.rpm List dependencies of a non-installed package
rpm -ivh package.src.rpm Install a source RPM, spec goes into /usr/src/RedHat/SPECS
rpmbuild -ba package.spec Build from installed source installed
rpm -qa --queryformat="%10{SIZE}\t%{NAME}\n" | sort -k1,1n List installed software packages in order of size

Notes:

  • Wildcards work with filenames, but not with package names.
  • Any package filename argument can be replaced with a full URL of where to get the package from.
  • --test to see what a command would do without actually doing it.
  • -v for verbose output.

Filed under: Linux, System administration | Comments (0)

Leave a comment

Login