Skip to main content

Yum cheatsheet of commands you'll actually use

· 2 min read

The Redhat yum cheat sheet (first google result) is full of commands I've never used. Here is a concise list that I hope better represents mine and other's usage during day-to-day or custom RPM related work:

Basics

yum install packageName
yum update packageName
yum remove packageName
# stop asking me yes-or-no [y/N]
yum install -y packageName

Install specific version

# format:
yum install packageName-version.version.architecture

# example:
yum install firefox-31.5.3-3.el7_1.x86_64

Install from a local file

yum localinstall package.rpm

Remote packages

Search remote packages by substring

yum search keyword

Available versions to install?

yum --showduplicates list packageName

Local packages

Check if a package is installed

The output format is different for the two options:

# Suggested command
> rpm -qa | grep "python"
python-libs-2.7.5-58.el7.x86_64
python-2.7.5-58.el7.x86_64
# OR
> yum list installed | grep "python"
python.x86_64 2.7.5-58.el7
python-libs.x86_64 2.7.5-58.el7

Where are the files installed?

rpm -ql packageName

Debugging errors or your own package

Clear yum cache

yum clean all
# on some systems you may additionally have to do this:
rm -rf /var/cache/yum/*

Download an RPM as a .rpm

yum install --downloadonly --downloaddir=/tmp packageName

Print post-install POSTIN scripts

rpm -qp --scripts localrpm.rpm