What is yum?
Yum is a tool that installs and updates software on Red Hat style Linux, such as CentOS, AlmaLinux and Rocky Linux. A repository is an online store of software. Yum reads a list of these stores. Each store has a small settings file. If the file is old or wrong, installs and updates fail.
You need root access for this guide. Root is the main administrator login of the server.
Tip: Yum is old. Newer systems use dnf, and yum is often just a link to it. The commands below work the same way with dnf.
Steps
- Connect to your server with SSH.
- List the stores yum knows.
This shows each active repository.yum repolist - Clear old saved data.
This removes saved lists, so yum fetches new ones.yum clean all - Build a fresh list.
This downloads the latest package lists.yum makecache - Update the software.
This shows what will be updated. Read it, then type y to continue.yum update
Add a new repository
- Go to the settings folder.
cd /etc/yum.repos.d/ - Many repositories come as a package. For example, EPEL:
This adds the EPEL store.yum install epel-release - Run
yum repolistagain to see it.
If a repository fails
- Read the error. It names the repository.
- Check that the server reaches the internet.
- CentOS 7 and 8 have reached end of life. Their old addresses moved. Update the
baseurllines in the files in/etc/yum.repos.d/or move to a supported system. - To skip a broken store once, use
yum --disablerepo=name update.
Warning: Updates can change software that your sites use. On a live server, take a backup or snapshot first. Do not edit files in
/etc/yum.repos.d/ without copying them first.Quick recap
- Yum gets software from repositories listed in
/etc/yum.repos.d/. - Run
yum clean allandyum makecacheto refresh. - Add stores with packages like
epel-release. - Take a backup before big updates.