>_cmd.script

yum

RPM-based package manager for RHEL/CentOS and older Fedora

Package Management

By CMD Script Team · 4 min read · Last updated

SYNTAX
yum [OPTIONS] COMMAND [PACKAGE...]

Options

Command options and flags
FlagDescription
searchSearch package names and summaries for a keyword, e.g. yum search nginx
installInstall one or more packages and their dependencies
removeUninstall a package (also erase/removes it, keeping dependencies unless orphaned)
infoShow detailed information about a package (version, size, description, repo)
updateUpdate one package, or all packages if none is specified
listList installed and/or available packages, e.g. yum list installed
-yAssume yes to all prompts, useful for non-interactive/scripted installs

Distribution compatibility

  • RHEL 7/8
  • CentOS 7
  • Fedora (older releases; dnf is the successor)
  • Amazon Linux 2

What it does

yum (Yellowdog Updater, Modified) is the high-level package manager for RPM-based distributions like RHEL, CentOS, and older Fedora releases. It builds on top of the low-level rpm tool by adding repository management and automatic dependency resolution: instead of manually tracking down and installing every dependency an RPM needs, yum fetches packages (and anything they depend on) from configured repositories and installs them all in the correct order. Modern Fedora and RHEL 8+ have moved to dnf as the successor, but yum command syntax remains widely recognized and, on many systems, yum is simply an alias/symlink to dnf.

Beginner examples

  • yum search nginx — search available repositories for packages matching "nginx"
  • yum install nginx — install the nginx package and any required dependencies
  • yum remove nginx — uninstall the nginx package
  • yum info nginx — show detailed metadata about the nginx package (version, repository, description)
yum install -y git

Advanced examples

  • Update all installed packages to their latest available versions: yum update
  • Update just one package: yum update kernel
  • List everything currently installed: yum list installed
  • Check what updates are available without installing them: yum check-update
  • Clean cached package metadata to force a fresh repository sync: yum clean all && yum makecache
yum install -y epel-release && yum install -y htop

Common mistakes

  • Running yum install interactively in a script and having it hang on the "Is this ok [y/N]" prompt — always add -y for automation.
  • Forgetting that yum remove packagename can also remove packages that depend on it, potentially taking out more than expected; review the transaction summary before confirming.
  • Assuming yum is available on Debian/Ubuntu-based systems — it's specific to RPM-based distributions; those systems use apt/apt-get instead.
  • Not running yum clean all after changing repository configuration, leading to yum using stale cached metadata and missing newly added packages.

Tips

  • Use yum provides "*/binaryname" to find which package supplies a specific command or file when you only know the executable name, not the package name.
  • yum history shows a log of past transactions (installs, updates, removals), and yum history undo <id> can roll one back.
  • On systems where dnf is installed alongside yum, running yum --version will often reveal it's actually calling dnf under the hood.

Best practices

  • Always run yum update (or at least yum check-update) regularly to keep security patches current, especially on internet-facing servers.
  • Enable only trusted, well-maintained repositories (like EPEL for RHEL/CentOS) rather than adding many third-party .repo files, to reduce dependency conflicts and security risk.
  • Use -y deliberately in scripts, but review planned changes with yum install --assumeno packagename or by reading the transaction summary in interactive use before confirming destructive operations.

Try it yourself

A simulated shell with a sample home directory — experiment freely, nothing leaves your browser. Type help to list supported commands.

Real-world use cases

  • Provisioning a new RHEL/CentOS server by installing required packages (yum install -y nginx postgresql git) as part of a setup script.
  • Patching a fleet of servers against a security advisory with yum update <package> during a maintenance window.
  • Investigating "command not found" errors by using yum provides to identify which package to install for a missing binary.

Common interview questions

  • What's the relationship between yum and dnf? dnf is yum's successor, offering a faster and more reliable dependency resolver; it became the default package manager in Fedora 22+ and RHEL/CentOS 8+, and on those systems yum is often just a compatibility alias for dnf.
  • How does yum differ from rpm? rpm installs a single package file directly and does not resolve dependencies on its own; yum manages repositories and automatically resolves and installs any dependencies a package needs.
  • How would you find out which package provides a missing command? yum provides "*/commandname" searches repository metadata for the package that installs a file matching that path pattern.

Frequently Asked Questions

What's the difference between yum and dnf?

dnf is the next-generation successor to yum, rewritten with a better dependency resolver and cleaner internals; it was adopted as the default in Fedora starting with Fedora 22 and later became the default in RHEL/CentOS 8. Most yum command syntax works unchanged under dnf, and on modern systems yum is often just a symlink to dnf.

How do I install a package without being prompted for confirmation?

Add -y: yum install -y nginx skips the interactive 'Is this ok [y/N]' prompt, which is essential for scripts and automation.

How does yum know what packages are available?

It reads repository definitions (.repo files, typically in /etc/yum.repos.d/) that point to remote or local package repositories, and caches their metadata locally so search/install commands can resolve packages and dependencies quickly.

How do I see what would be updated without actually updating?

yum check-update lists packages with available updates without installing anything.

Cheat sheet

Download a quick-reference cheat sheet for yum.