Getting started with yum

Getting Started with Yum on RPM‑Based Linux Distributions

guide

Getting Started with Yum on RPM‑Based Linux Distributions

Prerequisites

  • A Linux distribution that uses the RPM Package Manager (RHEL, CentOS, Fedora, AlmaLinux, Rocky Linux).
  • Root or sudo privileges.
  • Internet connectivity for downloading packages and repository metadata.

Installation of yum

  1. RHEL/CentOS 7 – yum is pre‑installed.
  2. RHEL/CentOS 8 and later – yum is replaced by dnf, but the yum command is provided as a compatibility wrapper (yumdnf).
  3. Fedorayum is not shipped; use dnf instead.
  4. AlmaLinux/Rocky Linux 8+ – same as RHEL 8; yum is a symlink to dnf.
  5. If yum is missing (e.g., minimal install), install it with the package manager that is present:
    sudo dnf install yum
    
    or for older systems:
    sudo yum install yum
    

Configuration of yum

  • Repository configuration – yum reads repo files from /etc/yum.repos.d/. Each .repo file contains sections like [base], [updates], etc. Example entry:
    [base]
    name=CentOS-$releasever - Base
    baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
    enabled=1
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
    
  • Global settings/etc/yum.conf holds global options such as cachedir, keepcache, debuglevel, logfile, exactarch, obsoletes, gpgcheck, plugins, etc.
  • Plugin system – yum plugins extend functionality (e.g., yum-plugin-fastestmirror, yum-plugin-security). Install with yum install yum-plugin-*.
  • Cache managementyum clean all clears metadata and package cache.
  • Transaction logging – logs are stored in /var/log/yum.log.

Basic yum usage

  • Install a package: sudo yum install <package>
  • Update a package: sudo yum update <package>
  • Remove a package: sudo yum remove <package>
  • Search for a package: yum search <keyword>
  • List installed packages: yum list installed
  • Check for available updates: yum check-update
  • Upgrade the entire system: sudo yum upgrade

Troubleshooting

  • Metadata errors – run yum clean all and retry.
  • Missing GPG key – import the key with rpm --import <key-url> or disable gpgcheck temporarily.
  • Repository not found – verify the baseurl and network connectivity.
  • Dependency conflicts – use yum deplist <package> to inspect dependencies.

Security and best practices

  • Keep the system’s GPG keys up to date.
  • Enable gpgcheck=1 in /etc/yum.conf.
  • Use the --security flag to install only security updates: yum update --security.
  • Regularly run yum update to apply patches.