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
- RHEL/CentOS 7 – yum is pre‑installed.
- RHEL/CentOS 8 and later – yum is replaced by dnf, but the
yumcommand is provided as a compatibility wrapper (yum→dnf). - Fedora –
yumis not shipped; usednfinstead. - AlmaLinux/Rocky Linux 8+ – same as RHEL 8;
yumis a symlink todnf. - If yum is missing (e.g., minimal install), install it with the package manager that is present:
or for older systems:sudo dnf install yumsudo yum install yum
Configuration of yum
- Repository configuration – yum reads repo files from
/etc/yum.repos.d/. Each.repofile 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.confholds global options such ascachedir,keepcache,debuglevel,logfile,exactarch,obsoletes,gpgcheck,plugins, etc. - Plugin system – yum plugins extend functionality (e.g.,
yum-plugin-fastestmirror,yum-plugin-security). Install withyum install yum-plugin-*. - Cache management –
yum clean allclears 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 alland retry. - Missing GPG key – import the key with
rpm --import <key-url>or disablegpgchecktemporarily. - 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=1in/etc/yum.conf. - Use the
--securityflag to install only security updates:yum update --security. - Regularly run
yum updateto apply patches.