yum
RPM-based package manager for RHEL/CentOS and older Fedora
By CMD Script Team · 4 min read · Last updated
yum [OPTIONS] COMMAND [PACKAGE...]Options
| Flag | Description |
|---|---|
search | Search package names and summaries for a keyword, e.g. yum search nginx |
install | Install one or more packages and their dependencies |
remove | Uninstall a package (also erase/removes it, keeping dependencies unless orphaned) |
info | Show detailed information about a package (version, size, description, repo) |
update | Update one package, or all packages if none is specified |
list | List installed and/or available packages, e.g. yum list installed |
-y | Assume 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 dependenciesyum remove nginx— uninstall the nginx packageyum 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 installinteractively in a script and having it hang on the "Is this ok [y/N]" prompt — always add-yfor automation. - Forgetting that
yum remove packagenamecan also remove packages that depend on it, potentially taking out more than expected; review the transaction summary before confirming. - Assuming
yumis available on Debian/Ubuntu-based systems — it's specific to RPM-based distributions; those systems useapt/apt-getinstead. - Not running
yum clean allafter 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 historyshows a log of past transactions (installs, updates, removals), andyum history undo <id>can roll one back.- On systems where
dnfis installed alongsideyum, runningyum --versionwill often reveal it's actually calling dnf under the hood.
Best practices
- Always run
yum update(or at leastyum 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
.repofiles, to reduce dependency conflicts and security risk. - Use
-ydeliberately in scripts, but review planned changes withyum install --assumeno packagenameor 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 providesto 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
yumis often just a compatibility alias fordnf. - How does yum differ from rpm?
rpminstalls a single package file directly and does not resolve dependencies on its own;yummanages 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.