How To Install Yum

How To Install Yum

Reading time1 min
#Linux#Sysadmin#PackageManagement#YUM#RPM#LinuxInstallation

Installing YUM on Minimal RPM-Based Systems

YUM (Yellowdog Updater, Modified) underpins package management on CentOS, RHEL, and older Fedora releases. On minimal or custom installations, you may be left with rpm and little else—no YUM, no dnf. This is a common scenario in hardened environments, air-gapped VMs, or small cloud images. Here’s how to bootstrap YUM when your system lacks it.


1. Confirm YUM Is Missing

Is YUM actually absent, or just broken? Terminal check:

$ yum --version
bash: yum: command not found

Occasionally, yum exists but is misconfigured. Investigate /usr/bin/yum and inspect for missing Python dependencies.


2. Determine Distribution & Version

YUM is relevant to:

  • RHEL/CentOS 6, 7
  • Fedora up to 21 (deprecated in favor of dnf after that)

For RHEL 8+ or Fedora 22+, skip to dnf (/usr/bin/dnf). If legacy applications require YUM, proceed, but expect diminishing support.

Retrieve OS version reliably:

cat /etc/os-release
# or
cat /etc/centos-release

3. Bootstrap YUM via RPM

On minimal installs, only rpm is available.

A. Download Required RPMs (Including Dependencies)

Identify which RPMs are needed for your version.

  • CentOS 7: Requires at least yum, python-iniparse, python-urlgrabber, and likely yum-metadata-parser.

Example (CentOS 7, x86_64):

wget http://mirror.centos.org/centos/7/os/x86_64/Packages/yum-3.4.3-168.el7.centos.noarch.rpm
wget http://mirror.centos.org/centos/7/os/x86_64/Packages/python-iniparse-0.4-9.el7.noarch.rpm
wget http://mirror.centos.org/centos/7/os/x86_64/Packages/python-urlgrabber-3.10-8.el7.noarch.rpm

Gotcha: Dependencies change by minor release. Don’t blindly mirror these versions on RHEL 8.

B. Install in Order of Dependencies

Rely on rpm rather than YUM itself.

sudo rpm -Uvh python-iniparse-0.4-9.el7.noarch.rpm
sudo rpm -Uvh python-urlgrabber-3.10-8.el7.noarch.rpm
sudo rpm -Uvh yum-3.4.3-168.el7.centos.noarch.rpm

If you encounter this error:

error: Failed dependencies:
    python(abi) = 2.7 is needed by yum-3.4.3-168.el7.centos.noarch

Your system might lack Python 2.7; install it first, typically as python or python2.


4. Validation

Re-check after install:

yum --version

Expected output:

3.4.3
Installed: rpm-4.11.3-48.el7.x86_64 at 2024-06-17 15:12:57

If you get Python tracebacks: likely a dependency issue. Run rpm -q --whatprovides <missing module> or search for appropriate provider RPMs.


5. Post-Install Tuning

YUM depends on /etc/yum.repos.d containing valid repo files. These are sometimes missing on bare installs. For CentOS7, consider:

sudo yum install centos-release

This command bootstraps the default repository configurations if networking is available.

Air-gapped scenario:
Transfer all necessary RPMs, dependencies, and repo files via USB/ISO or internal mirror. Keep in mind, YUM won’t resolve remote dependencies without a repo.


6. Migrating to DNF (RHEL 8, Fedora 22+)

YUM is deprecated in favor of dnf. For environments where dnf is missing, substitute equivalent RPM procedures:

sudo rpm -Uvh dnf-4.7.0-7.el8.noarch.rpm

Notably, dnf can execute most YUM commands via symlinks, but script compatibility may vary—test before adopting in automation.


Example: Installing nano With YUM

Once functional, package installation resumes:

sudo yum install nano

YUM resolves dependencies, unpacks, and configures software, as expected.


Non-Obvious Tip: Bootstrapping Repos Manually

If corporate policy prevents public mirrors, manually create minimal .repo files in /etc/yum.repos.d/. Point baseurl to your internal package server. Example:

[internal-base]
name=Internal Base Repo
baseurl=http://pkgs.corp.local/centos/7/os/x86_64/
enabled=1
gpgcheck=0

Summary Table

TaskCommand / Action
Check for YUMyum --version
Download RPMswget <url>
Install w/ rpmrpm -Uvh <package>
Confirm installyum --version
Repo bootstrapyum install centos-release or edit .repo manually

Known Issue

Some stripped cloud images remove not just yum but core utilities (wget, curl). Transfer RPMs manually in that case or use local package media. Don’t assume bash, Python, or networking are present—always verify your baseline.


YUM isn’t ideal for new projects—dnf or even package layering are preferred—but when supporting legacy or specialized environments, knowing how to hand-install YUM keeps your system manageable.

For unusual failures, review yum.log, dmesg, or strace the rpm process for more context.

No solution is perfect; sometimes, a chrooted bootstrap or reinstall is faster. Choose based on your SLA and team tolerance for system downtime.