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.

CommandPurpose
rpm -e package-1.2.3-gmErase named package from system
rpm -i package-1.2.3-gm.rpmInstall package file into system
rpm -U package-1.2.3-gmUpgrade package
rpm -F package1 package2Upgrade packages to latest versions in an appropriate order
rpm -Fvh *Upgrade a bunch of packages from the matching RPM files
rpm -q packageReturns full name and version of installed package
rpm -qp package.rpmSame for a non-installed package
rpm -qi packageReturns misc details about package
rpm -qpi package.rpmSame for a non-installed package
rpm -qaList all installed packages
rpm -qf fileWhich package put this file here?
rpm -ql packageList of files in an installed package
rpm -qlp package.rpmSame for files in a non-installed package
rpm -qRl packageList dependencies of an installed package
rpm -qR package.rpmList dependencies of a non-installed package
rpm -ivh package.src.rpmInstall a source RPM, spec goes into /usr/src/RedHat/SPECS
rpmbuild -ba package.specBuild from installed source installed

Also, to list installed software packages in order of size, with descriptions:

rpm -qa --queryformat="%10{size} %{NAME} - %{SUMMARY}n" | sort -k1,1nr

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.