How to fix yum errors on CentOS, RHEL or Fedora

Yum is a package management tool for installing, updating and removing rpm packages on Red Hat-based systems. When you try to install a package with yum command, you may encounter errors for various reasons. In this post, I will describe under what situations yum errors can occur, and explain how to fix yum errors.